-
Notifications
You must be signed in to change notification settings - Fork 247
Expand file tree
/
Copy pathgenerate.php
More file actions
30 lines (23 loc) · 1.14 KB
/
generate.php
File metadata and controls
30 lines (23 loc) · 1.14 KB
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
#!/usr/bin/php
<?php declare(strict_types=1);
use AwesomeList\Feed\EventFeedGenerator;
use AwesomeList\MarkdownGenerator;
use AwesomeList\Rendering\Stats;
use AwesomeList\Rendering\Toc;
use AwesomeList\SidecarState;
use AwesomeList\YamlEntryLoader;
require_once __DIR__ . '/vendor/autoload.php';
$markdownGenerator = new MarkdownGenerator();
$contents = $markdownGenerator->generate(__DIR__.'/content');
// Inject the stats block + auto-generated TOC after the tag-expansion pass.
$state = SidecarState::loadOrEmpty(__DIR__ . '/state/enrichment.json');
$stats = new Stats(new YamlEntryLoader());
$statsBlock = $stats->render($stats->collect(__DIR__ . '/data', $state));
$contents = str_replace('<!-- STATS -->', $statsBlock, $contents);
$tocBlock = (new Toc())->render($contents);
$contents = str_replace('<!-- TOC -->', $tocBlock, $contents);
file_put_contents(__DIR__ . '/README.md', $contents);
$feed = new EventFeedGenerator(new YamlEntryLoader(), new DateTimeImmutable());
$artifacts = $feed->generate(__DIR__ . '/data/events');
file_put_contents(__DIR__ . '/events.ical', $artifacts['ical']);
file_put_contents(__DIR__ . '/events.json', $artifacts['json']);