Skip to content

Commit 1eb106d

Browse files
committed
Revert "Fix prev-next in guide"
This reverts commit 4129b6f.
1 parent 4129b6f commit 1eb106d

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

site/controllers/guide.php

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
<?php
22

33
use Kirby\Cms\Page;
4-
use Kirby\Cms\Pages;
54

65
return function (Page $page) {
76

8-
if ($page->isChapter()) {
7+
if ($page->text()->isEmpty() && $page->hasChildren()) {
98
go($page->children()->first()->url());
109
}
1110

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-
2211
return [
23-
'guide' => $page,
24-
'menu' => $menu,
25-
'prevnext' => $prevnext->filterBy('isChapter', false)
12+
'guide' => $page,
2613
];
2714
};

site/models/guide.php

-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
class GuidePage extends Page
66
{
7-
public function isChapter(): bool
8-
{
9-
return $this->text()->isEmpty() && $this->hasChildren();
10-
}
11-
127
public function metadata(): array
138
{
149
return [

site/snippets/sidebar/menu-grouped.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php foreach ($menu as $category => $items): ?>
1+
<?php foreach ($menu->group('category') as $category => $items): ?>
22
<section class="sidebar-group">
33
<h2><?= option('categories')[$category] ?? ucfirst($category) ?></h2>
44
<?php snippet('sidebar/menu', ['menu' => $items, 'marginBottom' => 'mb-6']); ?>

site/templates/guide.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
<?php snippet('sidebar', [
55
'title' => 'Guide',
66
'link' => '/docs/guide',
7-
'menu' => $menu,
7+
'menu' => collection('guides'),
88
'hasCategories' => true,
99
]) ?>
1010
<?php endslot() ?>
1111

1212
<?php slot('prevnext') ?>
13-
<?php snippet('layouts/prevnext', ['siblings' => $prevnext]) ?>
13+
<?php snippet('layouts/prevnext', [
14+
'siblings' => page('docs/guide')->index()->listed()
15+
]) ?>
1416
<?php endslot() ?>

0 commit comments

Comments
 (0)