-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap.php
42 lines (36 loc) · 1.15 KB
/
bootstrap.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
<?php
use Illuminate\Support\Str;
use TightenCo\Jigsaw\Jigsaw;
use samdark\sitemap\Sitemap;
/** @var $container \Illuminate\Container\Container */
/** @var $events \TightenCo\Jigsaw\Events\EventBus */
/**
* You can run custom code at different stages of the build process by
* listening to the 'beforeBuild', 'afterCollections', and 'afterBuild' events.
*
* For example:
*
* $events->beforeBuild(function (Jigsaw $jigsaw) {
* // Your code here
* });
*/
$events->afterBuild(function (Jigsaw $jigsaw) {
$excludes = [
'/assets/*',
'/android-chrome-192x192.png',
'/android-chrome-512x512.png',
'/apple-touch-icon.png',
'*/favicon.ico',
'*/favicon*.png',
'*/404.html',
'/site.webmanifest',
];
$baseUrl = $jigsaw->getConfig('baseUrl');
$sitemap = new Sitemap($jigsaw->getDestinationPath() . '/sitemap.xml');
collect($jigsaw->getOutputPaths())
->reject(fn ($path) => Str::is($excludes, $path))
->each(function ($path) use ($baseUrl, $sitemap) {
$sitemap->addItem(rtrim($baseUrl, '/') . $path, time(), Sitemap::DAILY);
});
$sitemap->write();
});