Skip to content

Instantly share code, notes, and snippets.

@jasonmccreary
Created January 4, 2019 18:19
Show Gist options
  • Save jasonmccreary/9890185a5cf9644b5bb1fa5fd772d263 to your computer and use it in GitHub Desktop.
Save jasonmccreary/9890185a5cf9644b5bb1fa5fd772d263 to your computer and use it in GitHub Desktop.
Jigsaw Configuration for https://jasonmccreary.me
<?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