File tree 4 files changed +23
-7
lines changed
4 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
use Kirby \Cms \Page ;
4
+ use Kirby \Cms \Pages ;
4
5
5
6
return function (Page $ page ) {
6
7
7
- if ($ page ->text ()-> isEmpty () && $ page -> hasChildren ()) {
8
+ if ($ page ->isChapter ()) {
8
9
go ($ page ->children ()->first ()->url ());
9
10
}
10
11
12
+ $ menu = collection ('guides ' )->group ('category ' );
13
+ $ prevnext = new Pages ();
14
+
15
+ foreach ($ menu as $ guides ) {
16
+ foreach ($ guides as $ guide ) {
17
+ $ prevnext ->add ($ guide );
18
+ $ prevnext ->add ($ guide ->index ()->listed ());
19
+ }
20
+ }
21
+
11
22
return [
12
- 'guide ' => $ page ,
23
+ 'guide ' => $ page ,
24
+ 'menu ' => $ menu ,
25
+ 'prevnext ' => $ prevnext ->filterBy ('isChapter ' , false )
13
26
];
14
27
};
Original file line number Diff line number Diff line change 4
4
5
5
class GuidePage extends Page
6
6
{
7
+ public function isChapter (): bool
8
+ {
9
+ return $ this ->text ()->isEmpty () && $ this ->hasChildren ();
10
+ }
11
+
7
12
public function metadata (): array
8
13
{
9
14
return [
Original file line number Diff line number Diff line change 1
- <?php foreach ($ menu-> group ( ' category ' ) as $ category => $ items ): ?>
1
+ <?php foreach ($ menu as $ category => $ items ): ?>
2
2
<section class="sidebar-group">
3
3
<h2><?= option ('categories ' )[$ category ] ?? ucfirst ($ category ) ?> </h2>
4
4
<?php snippet ('sidebar/menu ' , ['menu ' => $ items , 'marginBottom ' => 'mb-6 ' ]); ?>
Original file line number Diff line number Diff line change 4
4
<?php snippet ('sidebar ' , [
5
5
'title ' => 'Guide ' ,
6
6
'link ' => '/docs/guide ' ,
7
- 'menu ' => collection ( ' guides ' ) ,
7
+ 'menu ' => $ menu ,
8
8
'hasCategories ' => true ,
9
9
]) ?>
10
10
<?php endslot () ?>
11
11
12
12
<?php slot ('prevnext ' ) ?>
13
- <?php snippet ('layouts/prevnext ' , [
14
- 'siblings ' => page ('docs/guide ' )->index ()->listed ()
15
- ]) ?>
13
+ <?php snippet ('layouts/prevnext ' , ['siblings ' => $ prevnext ]) ?>
16
14
<?php endslot () ?>
You can’t perform that action at this time.
0 commit comments