all repos — archive/homestead @ 1a36d4dc311a86246fe854da888af01f8195368e

My future indieweb platform

refactor: move tag indexing of posts to Posts

Alan Pearce
commit

1a36d4dc311a86246fe854da888af01f8195368e

parent

1f2a6245ab1e503dee017ab617aaeda816ecb383

1 file changed, 1 insertion(+), 8 deletions(-)

changed files
M src/index.jssrc/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', {