-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.php
46 lines (36 loc) · 1.04 KB
/
app.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
<?php
/**
* Bloge application
*
* @package bloge/meta-out-pack
*/
use Bloge\Apps\AdvancedApp;
use Bloge\Content\Advanced;
use Bloge\Content\Raw as Content;
use Bloge\Renderers\Twig as Renderer;
function twig_render ($string, array $data) {
$twig = new Twig_Environment(new Twig_Loader_String());
return $twig->render($string, $data);
}
$content = __DIR__ . '/content';
$theme = __DIR__ . '/theme';
$renderer = new Renderer($theme);
$content = new Advanced(new Content($content));
$content->processor()
->add(Bloge\process('content', [new Parsedown, 'text']))
->add(function ($route, $data) {
if ($route === 'blog') {
$data['content'] = twig_render($data['content'], $data);
}
return $data;
});
$content->dataMapper()
->mapAll([
'view' => 'page.twig'
])
->map(spyc_load_file(__DIR__ . '/meta.yml'))
->map('blog', [
'title' => 'Bloggin is awesome!',
'posts' => $content->browse('blog')
]);
return new AdvancedApp($content, $renderer);