summary refs log tree commit diff stats
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/index.js b/src/index.js
index 6df1530..52bdff0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -37,14 +37,21 @@ router.get('/post/:filename', async function (ctx) {
   })
 })
 
-const tags = Posts.toTags(posts)
-router.get('/tags/:tag', async function (ctx) {
-  ctx.assert(tags.has(ctx.params.tag), 404, 'Tag not found')
-  await ctx.render('tag', {
-    tag: ctx.params.tag,
-    posts: tags.get(ctx.params.tag)
+const taxonomies = Posts.taxonomise(config.taxonomies, posts)
+for (let [term, items] of taxonomies) {
+  router.get(`/${term}/:value`, async function (ctx) {
+    const value = ctx.params.value
+    ctx.assert(
+      items.has(ctx.params.value),
+      404,
+      `Could not find ${term} ${value}`
+    )
+    await ctx.render('tag', {
+      [term]: value,
+      posts: items.get(ctx.params.value)
+    })
   })
-})
+}
 
 app.use(router.routes()).use(router.allowedMethods())