Created
January 4, 2019 18:19
-
-
Save jasonmccreary/9890185a5cf9644b5bb1fa5fd772d263 to your computer and use it in GitHub Desktop.
Jigsaw Configuration for https://jasonmccreary.me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'baseUrl' => 'https://jasonmccreary.me', | |
'production' => true, | |
'siteName' => 'Jason McCreary', | |
'siteTitle' => 'I build things with my hands', | |
'siteDescription' => 'I build things with my hands', | |
'siteAuthor' => 'Jason McCreary', | |
// collections | |
'collections' => [ | |
'posts' => [ | |
'sort' => '-date', | |
'path' => 'articles/{filename}', | |
'readTime' => function($page) { | |
return intval(round(str_word_count(strip_tags($page->getContent())) / 200)); | |
}, | |
'publishedTime' => function($page) { | |
$now = \Carbon\Carbon::now(); | |
$published = \Carbon\Carbon::instance($page->getDate()); | |
$days_old = $published->diffInDays($now); | |
if ($days_old < 30) { | |
return $published->diffForHumans(); | |
} | |
if ($days_old < 365) { | |
return 'on ' . $published->format('F jS'); | |
} | |
return 'in ' . $published->format('Y'); | |
} | |
], | |
'categories' => [ | |
'path' => '/articles/categories/{-filename}', | |
'posts' => function ($page, $allPosts) { | |
return $allPosts->filter(function ($post) use ($page) { | |
$category = str_replace('-', ' ', title_case($page->getFilename())); | |
return $post->categories ? in_array($category, $post->categories, true) : false; | |
}); | |
}, | |
], | |
], | |
// helpers | |
'getDate' => function ($page) { | |
return Datetime::createFromFormat('U', $page->date); | |
}, | |
'isActive' => function ($page, $path) { | |
return ends_with(trimPath($page->getPath()), trimPath($path)); | |
}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment