Add the ability to create blog pages and blog-posts.

This commit is contained in:
2026-04-20 09:31:28 +10:00
parent 87999e63f8
commit ac10e95b51
6 changed files with 131 additions and 0 deletions

28
controllers/blog.php Normal file
View File

@@ -0,0 +1,28 @@
<?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");
};