about summary refs log tree commit diff stats
path: root/src/modules
diff options
context:
space:
mode:
authorAlan Pearce2017-06-18 17:23:06 +0200
committerAlan Pearce2017-06-18 17:23:06 +0200
commit1a36d4dc311a86246fe854da888af01f8195368e (patch)
treef4c433e96a9fabe690cda26cac5aa1d7a7f3ad45 /src/modules
parent1f2a6245ab1e503dee017ab617aaeda816ecb383 (diff)
downloadhomestead-1a36d4dc311a86246fe854da888af01f8195368e.tar.lz
homestead-1a36d4dc311a86246fe854da888af01f8195368e.tar.zst
homestead-1a36d4dc311a86246fe854da888af01f8195368e.zip
refactor: move tag indexing of posts to Posts
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/posts.js15
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
 }