diff --git a/src/Blog.php b/src/Blog.php index 1580f34..245271f 100644 --- a/src/Blog.php +++ b/src/Blog.php @@ -120,7 +120,7 @@ class Blog ); $app->get( - '/post/{post}', + '/post/{post:.+}', function (Request $request, Response $response, $args) { $post = $this->posts[$args['post']] ?? false; if ( ! $post) { @@ -213,7 +213,7 @@ class Blog private function parseObjects($path, $registerTags = false) { $objectBase = realpath($path); - $objects = glob($objectBase."/*.md"); + $objects = array_merge(glob($objectBase."/*.md") ?: [], glob($objectBase."/*/*.md") ?: []); $objectsColl = []; foreach ($objects as $object) { @@ -263,6 +263,11 @@ class Blog } $this->posts = $this->parseObjects(__DIR__."/../data/posts", true); + + uasort($this->posts, function ($a, $b) { + return $b['meta']['date']->getTimestamp() - $a['meta']['date']->getTimestamp(); + }); + $this->pages = $this->parseObjects(__DIR__."/../data/pages"); $this->games = $this->parseObjects(__DIR__."/../data/games");