-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·48 lines (44 loc) · 1.41 KB
/
index.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
<?php
// Set page `type` to `Markdown` by default
if (null !== State::get('x.markdown') && !State::get('x.page.page.type')) {
State::set('x.page.page.type', 'Markdown');
}
// Add CSS file to the `<head>` section…
if (defined('TEST') && TEST) {
Asset::set('index.css', 20);
} else {
// Serve the minified version if `TEST` mode is off
Asset::set('index.min.css', 20);
}
// Create site link data to be used in navigation
lot('links', new Anemone((static function ($links, $state, $url) {
$index = LOT . D . 'page' . D . trim(strtr($state->route, '/', D), D) . '.page';
$path = $url->path . '/';
foreach (g(LOT . D . 'page', 'page') as $k => $v) {
// Exclude home page
if ($k === $index) {
continue;
}
$v = new Page($k);
// Add current state
$v->current = 0 === strpos($path, '/' . $v->name . '/');
$links[$k] = $v;
}
ksort($links);
return $links;
})([], $state, $url)));
// Create site trace data to be used in navigation
lot('traces', new Pages((static function ($traces, $state, $url) {
$chops = explode('/', trim($url->path ?? "", '/'));
$v = LOT . D . 'page';
while ($chop = array_shift($chops)) {
$v .= D . $chop;
if ($file = exist([
$v . '.archive',
$v . '.page'
], 1)) {
$traces[] = $file;
}
}
return $traces;
})([], $state, $url)));