summaryrefslogtreecommitdiff
path: root/config.php
blob: 19350ee692515b192f2cc59a42cbcd41a25568e8 (plain)
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
43
44
45
<?php

use Illuminate\Support\Str;
use Carbon\Carbon;

$now = Carbon::now();

return [
    'baseUrl'         => 'http://localhost:3000',
    'production'      => false,
    'siteName'        => 'davidtsadler.com',
    'siteDescription' => 'My little bit of the Internet',
    'siteAuthor'      => 'David T. Sadler',
    'perPage'         => 50,

    'collections' => [
        'posts' => [
            // Default author, if not provided in a post
            'author' => 'David T. Sadler',
            'date'   => $now->timestamp,
            'sort'   => '-date',
            'path'   => '/posts/{date|Y-m-d}/{filename}',
        ],
        'tags' => [
            'path'  => '/tags/{filename}',
            'posts' => function ($page, $allPosts) {
                return $allPosts->filter(function ($post) use ($page) {
                    $tagSlugs = array_map(function ($tag) {
                        return Str::slug($tag);
                    }, $post->tags);
                    return $post->tags ? in_array($page->getFilename(), $tagSlugs, true) : false;
                });
            },
        ],
    ],

    // Helpers
    'getDate' => function ($page) {
        return $page->date ? Carbon::createFromFormat('U', $page->date) : null;
    },

    'allTags' => function ($page, $allPosts) {
        return $allPosts->pluck('tags')->flatten()->unique()->sort();
    },
];