From 248c74916e22f397ff95944ac2596b9e40b302e5 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 1 Jul 2017 11:00:25 +0200 Subject: feat: Add photo to marked-up h-chard --- config/default.toml | 5 ++++- src/responders.js | 10 ++++++---- src/templates/layout.html | 5 ++++- test/app.test.js | 4 +++- test/testsite/static/johndoe.jpg | Bin 0 -> 2133 bytes 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 test/testsite/static/johndoe.jpg diff --git a/config/default.toml b/config/default.toml index 9db7540..8683981 100644 --- a/config/default.toml +++ b/config/default.toml @@ -2,7 +2,10 @@ port = 3000 [site] -author = "John Doe" + +[site.author] +name = "John Doe" +photo = "/static/johndoe.jpg" [posts] folder = "./posts" diff --git a/src/responders.js b/src/responders.js index 7671141..e472579 100644 --- a/src/responders.js +++ b/src/responders.js @@ -76,11 +76,13 @@ module.exports = { templates .layout() .pipe(rheo()) + .attribute(".u-photo", "alt", config.site.author.name) + .attribute(".u-photo", "src", config.site.author.photo) .outer("main", showPage("home")) .inner(".posts", function(postsTemplate) { return postsStream.pipe(postsTemplate.map(renderPostListItem(ctx))); }) - .pipe(setTitle(config.site.author)) + .pipe(setTitle(config.site.author.name)) .render() ); }, @@ -94,7 +96,7 @@ module.exports = { .outer("main", showPage("post")) .inner("article h1", rheo(post.data.get("title"))) .outer("article main", rheo(post.body)) - .pipe(setTitle(config.site.author, post.data.get("title"))) + .pipe(setTitle(config.site.author.name, post.data.get("title"))) .render() ); }, @@ -106,11 +108,11 @@ module.exports = { .layout() .pipe(rheo()) .outer("main", showPage("taxon")) - .inner("h1", rheo(config.site.author)) + .inner("h1", rheo(config.site.author.name)) .inner(".posts", function(postsTemplate) { return taxonItems.pipe(postsTemplate.map(renderPostListItem(ctx))); }) - .pipe(setTitle(config.site.author)) + .pipe(setTitle(config.site.author.name)) .render() ); } diff --git a/src/templates/layout.html b/src/templates/layout.html index 7856917..6e32bb4 100644 --- a/src/templates/layout.html +++ b/src/templates/layout.html @@ -6,7 +6,10 @@
-

hello world

+ + +

hello world

+
diff --git a/test/app.test.js b/test/app.test.js index 74aeac5..f3d8f07 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -46,7 +46,9 @@ test("homepage", t => { t.deepEqual(data.items, [ { properties: { - name: ["John Doe"] + name: ["John Doe"], + url: ["/"], + photo: ["/static/johndoe.jpg"] }, type: ["h-card"] } diff --git a/test/testsite/static/johndoe.jpg b/test/testsite/static/johndoe.jpg new file mode 100644 index 0000000..bc7b73d Binary files /dev/null and b/test/testsite/static/johndoe.jpg differ -- cgit 1.4.1