-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
61 lines (55 loc) · 1.73 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
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$z = defined('TEST') && TEST ? '.' : '.min.';
Asset::set(__DIR__ . D . 'index' . $z . 'css', 20);
Asset::set(__DIR__ . D . 'index' . $z . 'js', 20);
$states = [
'route-about' => '/about',
'route-album' => '/article',
'route-contact' => '/contact',
'x.comment.page.type' => 'Markdown',
'x.page.page.type' => 'Markdown'
];
foreach ($states as $k => $v) {
!State::get($k) && State::set($k, $v);
}
foreach (['about', 'contact'] as $v) {
$folder = LOT . D . 'page' . D . trim($state->{f2p('route-' . $v)} ?? $v, '/');
if ($file = exist([
$folder . '.archive',
$folder . '.page'
], 1)) {
lot($v, new Page($file));
} else {
lot($v, new Page);
}
}
Hook::set('page.content', function ($content) {
if (!$content) {
return $content;
}
$content = strtr($content, [
'<blockquote>' => '<blockquote class="blockquote">',
'<table>' => '<table class="table">'
]);
if (false !== strpos($content, '<img ')) {
$content = preg_replace_callback('/<img(\s[^>]*?)?>/', static function ($m) {
$img = new HTML($m[0]);
$img_classes = preg_split('/\s+/', $img['class'] ?? "", -1, PREG_SPLIT_NO_EMPTY);
$img_classes[] = 'img-fluid';
$img_classes[] = 'rounded';
sort($img_classes);
$img['class'] = implode(' ', array_unique($img_classes));
return (string) $img;
}, $content);
}
return $content;
});
Hook::set('y.t-o-c', function ($y) {
$class = preg_split('/\s+/', $y[2]['class'] ?? "", -1, PREG_SPLIT_NO_EMPTY);
$class[] = 'mb-4';
sort($class);
if ($class) {
$y[2]['class'] = \implode(' ', \array_unique($class));
}
return $y;
});