diff options
Diffstat (limited to 'config.php')
| -rw-r--r-- | config.php | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -17,9 +17,17 @@ return [ 'posts' => [ // Default author, if not provided in a post 'author' => 'David T. Sadler', - 'date' => $now->timestamp, 'sort' => '-date', 'path' => '/posts', + 'filter' => function ($item) use ($now) { + // Include every post if in development. + if (!$item->production) { + return true; + } + // 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}', @@ -35,8 +43,9 @@ return [ ], // Helpers - 'getDate' => function ($page) { - return $page->date ? Carbon::createFromFormat('U', $page->date) : null; + 'getDate' => function ($page) use ($now) { + // Use post date if one has been specified. Otherwise default to today's date in development. + return $page->date ? Carbon::createFromFormat('U', $page->date) : ($page->production ? null : $now); }, 'allTags' => function ($page, $allPosts) { |
