diff options
-rw-r--r-- | config/default.toml | 8 | ||||
-rw-r--r-- | src/responders.js | 9 | ||||
-rw-r--r-- | src/templates/layout.html | 7 | ||||
-rw-r--r-- | test/app.test.js | 13 | ||||
-rw-r--r-- | test/snapshots/app.test.js.md | 76 | ||||
-rw-r--r-- | test/snapshots/app.test.js.snap | bin | 1658 -> 1880 bytes |
6 files changed, 102 insertions, 11 deletions
diff --git a/config/default.toml b/config/default.toml index 0a55027..d2efd7a 100644 --- a/config/default.toml +++ b/config/default.toml @@ -11,6 +11,14 @@ url = "/" name = "John Doe" photo = "/static/johndoe.jpg" +[[author.contact]] +url = "mailto:johndoe@johndoe.org" +text = "johndoe@johndoe.org" + +[[author.contact]] +url = "https://twitter.com/johndoe" +text = "Twitter" + [posts] folder = "./posts" diff --git a/src/responders.js b/src/responders.js index f29b2b0..eeec42a 100644 --- a/src/responders.js +++ b/src/responders.js @@ -76,7 +76,14 @@ function layout(config, pageTitle, pageElement) { _text: l.text } })), - "body > main": pageElement.outerHTML + "body > main": pageElement.outerHTML, + ".contact-list li": config.author.contact.map(c => ({ + a: { + class: c.url.startsWith("mailto") ? "u-email" : "u-url", + href: c.url, + _text: c.text + } + })) }).outerHTML.trim(); } diff --git a/src/templates/layout.html b/src/templates/layout.html index 86eec59..6035209 100644 --- a/src/templates/layout.html +++ b/src/templates/layout.html @@ -18,5 +18,12 @@ </nav> </header> <main></main> + <footer> + <ul class="contact-list"> + <li> + <a rel="me" href="mailto:dog@johndoe.org">dog</a> + </li> + </ul> + </footer> </body> </html> diff --git a/test/app.test.js b/test/app.test.js index 1f8e72f..f0ab3da 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -47,6 +47,11 @@ test("homepage", async function(t) { t.is($("main").length, 1, "only one <main> tag"); t.is($("nav a").first().text(), "Home", "nav link has text"); t.is($("nav a").first().attr("href"), "/", "nav links to homepage"); + t.is( + $("a[rel=me]").length, + 2, + "renders author.contact config to rel=me links" + ); const options = toMicroformatsOptions($); const count = await mf.countAsync(options); @@ -55,7 +60,7 @@ test("homepage", async function(t) { "h-card": 1, "h-feed": 1, "h-entry": 1, - rels: 1 + rels: 3 }); const data = await mf.getAsync(options); @@ -86,7 +91,7 @@ test("posts", async function(t) { "h-card": 1, "h-feed": 1, "h-entry": 1, - rels: 1 + rels: 3 }); const data = await mf.getAsync(options); @@ -117,7 +122,7 @@ test("post", async function(t) { t.deepEqual(count, { "h-card": 1, "h-entry": 1, - rels: 1 + rels: 3 }); const data = await mf.getAsync(options); @@ -147,7 +152,7 @@ test("tags", async function(t) { "h-card": 1, "h-feed": 1, "h-entry": 1, - rels: 1 + rels: 3 }); const data = await mf.getAsync(options); diff --git a/test/snapshots/app.test.js.md b/test/snapshots/app.test.js.md index 02eac70..599fe22 100644 --- a/test/snapshots/app.test.js.md +++ b/test/snapshots/app.test.js.md @@ -62,8 +62,24 @@ Generated by [AVA](https://ava.li). 'stylesheet', ], }, + 'https://twitter.com/johndoe': { + rels: [ + 'me', + ], + text: 'Twitter', + }, + 'mailto:johndoe@johndoe.org': { + rels: [ + 'me', + ], + text: 'johndoe@johndoe.org', + }, }, rels: { + me: [ + 'mailto:johndoe@johndoe.org', + 'https://twitter.com/johndoe', + ], stylesheet: [ '/css/code.css', ], @@ -118,15 +134,31 @@ Generated by [AVA](https://ava.li). 'stylesheet', ], }, + 'https://twitter.com/johndoe': { + rels: [ + 'me', + ], + text: 'Twitter', + }, + 'mailto:johndoe@johndoe.org': { + rels: [ + 'me', + ], + text: 'johndoe@johndoe.org', + }, }, rels: { + me: [ + 'mailto:johndoe@johndoe.org', + 'https://twitter.com/johndoe', + ], stylesheet: [ '/css/code.css', ], }, } -## tags +## posts > should contain relevant microformats data @@ -170,7 +202,7 @@ Generated by [AVA](https://ava.li). ], properties: { name: [ - 'A · John Doe', + 'Posts · John Doe', ], }, type: [ @@ -184,15 +216,31 @@ Generated by [AVA](https://ava.li). 'stylesheet', ], }, + 'https://twitter.com/johndoe': { + rels: [ + 'me', + ], + text: 'Twitter', + }, + 'mailto:johndoe@johndoe.org': { + rels: [ + 'me', + ], + text: 'johndoe@johndoe.org', + }, }, rels: { + me: [ + 'mailto:johndoe@johndoe.org', + 'https://twitter.com/johndoe', + ], stylesheet: [ '/css/code.css', ], }, - + } -## posts +## tags > should contain relevant microformats data @@ -236,7 +284,7 @@ Generated by [AVA](https://ava.li). ], properties: { name: [ - 'Posts · John Doe', + 'A · John Doe', ], }, type: [ @@ -250,10 +298,26 @@ Generated by [AVA](https://ava.li). 'stylesheet', ], }, + 'https://twitter.com/johndoe': { + rels: [ + 'me', + ], + text: 'Twitter', + }, + 'mailto:johndoe@johndoe.org': { + rels: [ + 'me', + ], + text: 'johndoe@johndoe.org', + }, }, rels: { + me: [ + 'mailto:johndoe@johndoe.org', + 'https://twitter.com/johndoe', + ], stylesheet: [ '/css/code.css', ], }, - } \ No newline at end of file + } diff --git a/test/snapshots/app.test.js.snap b/test/snapshots/app.test.js.snap index b7ca373..dd02042 100644 --- a/test/snapshots/app.test.js.snap +++ b/test/snapshots/app.test.js.snap Binary files differ |