diff options
author | Alan Pearce | 2017-06-18 17:23:06 +0200 |
---|---|---|
committer | Alan Pearce | 2017-06-18 17:23:06 +0200 |
commit | 1a36d4dc311a86246fe854da888af01f8195368e (patch) | |
tree | f4c433e96a9fabe690cda26cac5aa1d7a7f3ad45 /src/index.js | |
parent | 1f2a6245ab1e503dee017ab617aaeda816ecb383 (diff) | |
download | homestead-1a36d4dc311a86246fe854da888af01f8195368e.tar.lz homestead-1a36d4dc311a86246fe854da888af01f8195368e.tar.zst homestead-1a36d4dc311a86246fe854da888af01f8195368e.zip |
refactor: move tag indexing of posts to Posts
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/index.js b/src/index.js index e811be0..07d7249 100644 --- a/src/index.js +++ b/src/index.js @@ -29,14 +29,7 @@ router.get('/post/:filename', async function (ctx) { }) }) -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', { |