about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2017-07-01 13:30:57 +0200
committerAlan Pearce2017-07-01 13:30:57 +0200
commitab3c5ffb57980359a186936aa6fc2894f58eb625 (patch)
tree1901135c0419fe1e70a7ab86fde330f5f8bc9a23
parente4e26ceca7bfe60185082748c54f7ccd30746350 (diff)
downloadhomestead-ab3c5ffb57980359a186936aa6fc2894f58eb625.tar.lz
homestead-ab3c5ffb57980359a186936aa6fc2894f58eb625.tar.zst
homestead-ab3c5ffb57980359a186936aa6fc2894f58eb625.zip
feat(taxon): Show taxonomy term in title
-rw-r--r--package.json1
-rw-r--r--src/actions.js2
-rw-r--r--src/responders.js5
-rw-r--r--src/templates/taxon.html12
-rw-r--r--test/app.test.js8
-rw-r--r--yarn.lock4
6 files changed, 20 insertions, 12 deletions
diff --git a/package.json b/package.json
index db17e2f..6cb7921 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
     "supertest": "^3.0.0"
   },
   "dependencies": {
+    "case": "^1.5.2",
     "configly": "^4.1.0",
     "gray-matter": "^2.1.1",
     "hyperfast": "^2.1.0",
diff --git a/src/actions.js b/src/actions.js
index 11acff5..8a04671 100644
--- a/src/actions.js
+++ b/src/actions.js
@@ -26,7 +26,7 @@ function taxonGenerator(config, term, items) {
 
     const taxonItems = items.get(value);
 
-    responders.taxon(ctx, config, taxonItems);
+    responders.taxon(ctx, config, term, value, taxonItems);
   };
 }
 
diff --git a/src/responders.js b/src/responders.js
index b9758f3..e285018 100644
--- a/src/responders.js
+++ b/src/responders.js
@@ -1,6 +1,7 @@
 "use strict";
 
 const fs = require("fs");
+const Case = require("case");
 const hyperfast = require("hyperfast");
 const indent = require("indent-string");
 
@@ -86,12 +87,12 @@ module.exports = {
     );
   },
 
-  taxon(ctx, config, taxonItems) {
+  taxon(ctx, config, term, value, taxonItems) {
     ctx.type = "html";
 
     ctx.body = layout(
       config,
-      null,
+      Case.title(value),
       hyperfast(templates.taxon, {
         ".post": taxonItems.map(renderPostListItem(ctx))
       })
diff --git a/src/templates/taxon.html b/src/templates/taxon.html
index 44e1bdc..97ac89a 100644
--- a/src/templates/taxon.html
+++ b/src/templates/taxon.html
@@ -1,7 +1,5 @@
-<main class="taxon">
-  <ul class="posts">
-    <li class="post">
-      <a href="/">Test post please ignore</a>
-    </li>
-  </ul>
-</main>
+<ul class="posts">
+  <li class="post">
+    <a href="/">Test post please ignore</a>
+  </li>
+</ul>
diff --git a/test/app.test.js b/test/app.test.js
index 3cffaf5..92a7a76 100644
--- a/test/app.test.js
+++ b/test/app.test.js
@@ -89,8 +89,12 @@ test("tags", t => {
   return request(app.listen())
     .get("/tag/a")
     .expect(200)
-    .expect(/This is a test/)
-    .then(() => t.pass());
+    .expect(/^<!DOCTYPE html>/)
+    .then(parseResponse)
+    .then($ => {
+      t.is($("head > title").text(), "A ยท John Doe");
+      t.is($(".post a").text(), "This is a test");
+    });
 });
 
 test("tags not found", t =>
diff --git a/yarn.lock b/yarn.lock
index d623708..48d071d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -793,6 +793,10 @@ cardinal@^1.0.0:
     ansicolors "~0.2.1"
     redeyed "~1.0.0"
 
+case@^1.5.2:
+  version "1.5.2"
+  resolved "https://registry.yarnpkg.com/case/-/case-1.5.2.tgz#28e8dbdd1312c5d55f344d44240689b92e0da168"
+
 caseless@~0.11.0:
   version "0.11.0"
   resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7"