forked from julienbourdeau/debugbar.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
44 lines (36 loc) · 1.24 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
43
44
<?php
use TightenCo\Jigsaw\Jigsaw;
/** @var \Illuminate\Container\Container $container */
/** @var \TightenCo\Jigsaw\Events\EventBus $events */
if (class_exists("Dotenv\Dotenv")) {
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
}
/*
* 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->beforeBuild(function (Jigsaw $jigsaw) {
$manifest = json_decode(file_get_contents(__DIR__.'/source/assets/debugbar/manifest.json'), true);
$jigsaw->setConfig('debugbarAssets', [
'js' => basename($manifest['src/demo.ts']['file']),
]);
});
$events->afterCollections(function (Jigsaw $jigsaw) {
global $docsToc; // YOLO
$docsToc = $jigsaw->getCollection('docs')->map(function ($page) {
return [
'title' => $page->title,
'section' => $page->toc_section,
'url' => $page->getPath(),
'disabled' => $page->disabled ?? false,
];
})->values()->groupBy('section');
});
\Torchlight\Jigsaw\TorchlightExtension::make($container, $events)->boot();