From b6040ea2ab6d4510fab5e3911132b0deb7017642 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Fri, 27 Mar 2020 16:26:54 +0000 Subject: Allow posts to be unpublished or scheduled in the future --- config.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config.php b/config.php index 495952e..289ee43 100644 --- a/config.php +++ b/config.php @@ -1,6 +1,9 @@ 'http://localhost:3000', @@ -17,6 +20,11 @@ return [ 'author' => 'David T. Sadler', 'sort' => '-date', 'path' => '/posts/{date|Y-m-d}/{filename}', + 'filter' => function ($item) use ($now) { + // Only publish posts that have a date and which is not in the future. + $date = $item->getDate(); + return $date ? $date <= $now : false; + } ], 'tags' => [ 'path' => '/tags/{filename}', @@ -33,7 +41,7 @@ return [ // Helpers 'getDate' => function ($page) { - return Datetime::createFromFormat('U', $page->date); + return $page->date ? Carbon::createFromFormat('U', $page->date) : null; }, 'allTags' => function ($page, $allPosts) { -- cgit v1.2.3-13-gbd6f