about summary refs log tree commit diff stats
path: root/src/domain
diff options
context:
space:
mode:
authorAlan Pearce2017-10-03 15:30:54 +0200
committerAlan Pearce2017-10-03 15:30:54 +0200
commitad56116d0df26b4a6fe7f9cd04a21965d3184af5 (patch)
treeb8fcb4944e9e0d60cbe11b2226b9acd42713b7f7 /src/domain
parent84da95bc4a8374bd3962e2479df560c67a1b94ca (diff)
downloadhomestead-ad56116d0df26b4a6fe7f9cd04a21965d3184af5.tar.lz
homestead-ad56116d0df26b4a6fe7f9cd04a21965d3184af5.tar.zst
homestead-ad56116d0df26b4a6fe7f9cd04a21965d3184af5.zip
Reify taxonomies into just tags.
I'm probably not going to need anything else, and this makes it a lot clearer
Diffstat (limited to 'src/domain')
-rw-r--r--src/domain/posts.js22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/domain/posts.js b/src/domain/posts.js
index c6b57c5..1214072 100644
--- a/src/domain/posts.js
+++ b/src/domain/posts.js
@@ -68,33 +68,29 @@ async function getFolder(folder, getURL) {
   return new Map(posts.map(f => [getTitle(f), f]));
 }
 
-function taxonomise(taxonomies, posts) {
-  const taxons = new Map(Object.keys(taxonomies).map(t => [t, new Map()]));
+function tag(posts) {
+  const tags = new Map();
 
   for (let [, post] of posts) {
-    for (let [singularName, pluralName] of Object.entries(taxonomies)) {
-      if (post.data.has(pluralName)) {
-        for (let term of post.data.get(pluralName)) {
-          const current = taxons.get(singularName).get(term);
-          taxons
-            .get(singularName)
-            .set(term, current ? current.concat(post) : [post]);
-        }
+    if (post.data.has("tags")) {
+      for (let term of post.data.get("tags")) {
+        const current = tags.get(term);
+        tags.set(term, current ? current.concat(post) : [post]);
       }
     }
   }
 
-  return taxons;
+  return tags;
 }
 
 module.exports = async function(config, getURL) {
   const posts = await getFolder(config.folder, getURL);
-  const taxonomies = taxonomise(config.taxonomies, posts);
+  const tags = tag(posts);
   const lastPostDate = Math.max(Array.from(posts.values(), p => p.date));
   return {
     lastPostDate,
     posts,
-    taxonomies,
+    tags,
     get
   };
 };