-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.php
54 lines (47 loc) · 1.73 KB
/
config.php
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
46
47
48
49
50
51
52
53
54
<?php
use Illuminate\Support\Str;
return [
'baseUrl' => 'http://kennyhorna.test',
'production' => false,
'siteName' => "Kenny Horna.",
'siteDescription' => 'Un lugar donde comparto las cosas que me interesan.',
'siteAuthor' => 'Kenny Horna',
'sections' => ['series', 'laravel', 'tips', 'tutoriales'],
// collections
'collections' => [
'posts' => [
'author' => 'Kenny Horna', // Default author, if not provided in a post
'sort' => '-date',
'path' => 'blog/{filename}',
],
'categories' => [
'path' => '/blog/secciones/{filename}',
'posts' => function ($page, $allPosts) {
return $allPosts->filter(function ($post) use ($page) {
return $post->categories ? in_array($page->getFilename(), $post->categories, true) : false;
});
},
],
],
// helpers
'getDate' => function ($page) {
return Datetime::createFromFormat('U', $page->date);
},
'getExcerpt' => function ($page, $length = 255) {
$content = $page->excerpt ?? $page->getContent();
$cleaned = strip_tags(
preg_replace(['/<pre>[\w\W]*?<\/pre>/', '/<h\d>[\w\W]*?<\/h\d>/'], '', $content),
'<code>'
);
$truncated = substr($cleaned, 0, $length);
if (substr_count($truncated, '<code>') > substr_count($truncated, '</code>')) {
$truncated .= '</code>';
}
return strlen($cleaned) > $length
? preg_replace('/\s+?(\S+)?$/', '', $truncated) . '...'
: $cleaned;
},
'isActive' => function ($page, $path) {
return Str::endsWith(trimPath($page->getPath()), trimPath($path));
},
];