summaryrefslogtreecommitdiff
path: root/config.php
diff options
context:
space:
mode:
authorDavid T. Sadler <davidtsadler@googlemail.com>2020-03-27 16:26:54 +0000
committerDavid T. Sadler <davidtsadler@googlemail.com>2020-03-27 16:26:54 +0000
commitb6040ea2ab6d4510fab5e3911132b0deb7017642 (patch)
treed6da338de8c3101e0e4037f7d85671a0fadd4767 /config.php
parentc09305bfcf14707ef8c6b46e4e39a03c42a5c746 (diff)
Allow posts to be unpublished or scheduled in the future
Diffstat (limited to 'config.php')
-rw-r--r--config.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/config.php b/config.php
index 495952e..289ee43 100644
--- a/config.php
+++ b/config.php
@@ -1,6 +1,9 @@
<?php
use Illuminate\Support\Str;
+use Carbon\Carbon;
+
+$now = Carbon::now();
return [
'baseUrl' => '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) {