diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/posts.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/modules/posts.js b/src/modules/posts.js index 834d45c..011292b 100644 --- a/src/modules/posts.js +++ b/src/modules/posts.js @@ -44,7 +44,20 @@ function getFolder (folder) { ) } +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 } |