37 lines
684 B
PHP
37 lines
684 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LogseqGem;
|
|
|
|
class GemlogRender {
|
|
public $articles = [];
|
|
|
|
public function addArticle(string $title, string $date, string $path) {
|
|
$this->articles[] = [$title, $date, $path];
|
|
}
|
|
|
|
public function render() {
|
|
$gemlog = [];
|
|
|
|
usort($this->articles, fn ($a, $b) => $b[1] <=> $a[1]);
|
|
|
|
foreach ($this->articles as $article) {
|
|
$gemlog[] = sprintf('=> %s %s %s', $article[2], $article[1], $article[0]);
|
|
}
|
|
|
|
|
|
$gemlog = implode("\n", $gemlog);
|
|
|
|
return <<<EOF
|
|
# Annika's Gemlog
|
|
|
|
$gemlog
|
|
|
|
=> atom.xml Atom feed
|
|
|
|
=> / home
|
|
EOF;
|
|
}
|
|
}
|