diff options
| -rw-r--r-- | config.php | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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) { |
