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, 14 insertions(+), 1 deletion(-)

changed files
M src/modules/posts.jssrc/modules/posts.js
@@ -44,7 +44,20 @@ .map(f => [getTitle(f), f])
) } +function toTags (posts) { + 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])) + } + } + } + return tags +} + module.exports = { get, - getFolder + getFolder, + toTags }