1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<?php
use Illuminate\Support\Str;
return [
'baseUrl' => '',
'production' => false,
'siteName' => 'David T. Sadler',
'siteDescription' => 'My little bit of the Internet',
'siteAuthor' => 'David T. Sadler',
'perPage' => 2,
// Collections
'collections' => [
'posts' => [
// Default author, if not provided in a post
'author' => 'David T. Sadler',
'sort' => '-date',
'path' => '/{filename}',
],
'categories' => [
'path' => '/categories/{filename}',
'posts' => function ($page, $allPosts) {
return $allPosts->filter(function ($post) use ($page) {
$categorySlugs = array_map(function ($category) {
return Str::slug($category);
}, $post->categories);
return $post->categories ? in_array($page->getFilename(), $categorySlugs, true) : false;
});
},
],
],
// Helpers
'getDate' => function ($page) {
return Datetime::createFromFormat('U', $page->date);
},
'allCategories' => function ($page, $allPosts) {
return $allPosts->pluck('categories')->flatten()->unique();
},
];
|