29 lines
1.0 KiB
PHP
29 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* Copyright 2026, Dreytac <dreytac@hobbyhome.net>
|
|
*
|
|
* This file is part of Kirby Blog.
|
|
*
|
|
* Kirby Blog is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
*
|
|
* Kirby Blog is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License along with Kirby Blog. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
return function ($page) {
|
|
$posts = new Pages();
|
|
|
|
if ($user = kirby()->user() and $user->role()->isAdmin()) {
|
|
$posts = $page->childrenAndDrafts();
|
|
} else {
|
|
$posts = $page->children();
|
|
}
|
|
|
|
$posts = $posts->sortBy("pinned", SORT_DESC, "updated", SORT_DESC);
|
|
|
|
$posts = $posts->paginate($page->postsPerPage()->toInt());
|
|
|
|
return compact("posts");
|
|
};
|