File tree 4 files changed +7
-23
lines changed
4 files changed +7
-23
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 ;
5
4
6
5
return function (Page $ page ) {
7
6
8
- if ($ page ->isChapter ()) {
7
+ if ($ page ->text ()-> isEmpty () && $ page -> hasChildren ()) {
9
8
go ($ page ->children ()->first ()->url ());
10
9
}
11
10
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
-
22
11
return [
23
- 'guide ' => $ page ,
24
- 'menu ' => $ menu ,
25
- 'prevnext ' => $ prevnext ->filterBy ('isChapter ' , false )
12
+ 'guide ' => $ page ,
26
13
];
27
14
};
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
-
12
7
public function metadata (): array
13
8
{
14
9
return [
Original file line number Diff line number Diff line change 1
- <?php foreach ($ menu as $ category => $ items ): ?>
1
+ <?php foreach ($ menu-> group ( ' category ' ) 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 ' => $ menu ,
7
+ 'menu ' => collection ( ' guides ' ) ,
8
8
'hasCategories ' => true ,
9
9
]) ?>
10
10
<?php endslot () ?>
11
11
12
12
<?php slot ('prevnext ' ) ?>
13
- <?php snippet ('layouts/prevnext ' , ['siblings ' => $ prevnext ]) ?>
13
+ <?php snippet ('layouts/prevnext ' , [
14
+ 'siblings ' => page ('docs/guide ' )->index ()->listed ()
15
+ ]) ?>
14
16
<?php endslot () ?>
You can’t perform that action at this time.
0 commit comments