From 62d3f0ab14e563b6cdaf4c2e36a3b1833d31b735 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Sun, 15 Oct 2017 17:36:59 +0100 Subject: [PATCH] Improved title of pages --- app.js | 6 ++++++ templates/partials/head.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 6988805..7b0c6d0 100644 --- a/app.js +++ b/app.js @@ -39,6 +39,12 @@ Handlebars.registerHelper('moment', function(date, format) { Handlebars.registerHelper("striptags", function(text){ return striptags(text); }); +Handlebars.registerHelper("buildTitle", function(title, siteTitle){ + if (title.indexOf(siteTitle) < 0) { + title = `'${title}' by ${siteTitle}`; + } + return title; +}); Metalsmith(__dirname) diff --git a/templates/partials/head.html b/templates/partials/head.html index d5dd127..4cff1c9 100644 --- a/templates/partials/head.html +++ b/templates/partials/head.html @@ -3,7 +3,7 @@ - {{ site.title }} + {{ buildTitle title site.title }}