refactor: move tag indexing of posts to Posts
1 file changed, 1 insertion(+), 8 deletions(-)
changed files
M src/index.js → src/index.js
@@ -29,14 +29,7 @@ post: posts.get(ctx.params.filename) }) }) -const tags = new Map() -for (let [, post] of posts) { - if (post.data.has('tags')) { - for (let tag of post.data.get('tags')) { - tags.set(tag, (tags.get(tag) || []).concat([post])) - } - } -} +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', {