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/src/css/main.scss b/src/css/main.scss index 83ff8e2..39aab3b 100644 --- a/src/css/main.scss +++ b/src/css/main.scss @@ -159,3 +159,25 @@ footer { height: 40px; } } + + +.share { + background: transparent; + border: none; + display: none; + cursor: pointer; + + &.show { + display: initial; + } + + &:hover, &:active { + fill: $link-color; + color: $link-color; + } + + svg { + height: 20px; + vertical-align: bottom; + } +} 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 }} diff --git a/templates/partials/share.html b/templates/partials/share.html new file mode 100644 index 0000000..b2b8292 --- /dev/null +++ b/templates/partials/share.html @@ -0,0 +1,6 @@ + diff --git a/templates/post.html b/templates/post.html index 2974061..4fd4d0a 100644 --- a/templates/post.html +++ b/templates/post.html @@ -9,7 +9,7 @@

- {{ title }} + {{ title }} {{> share }}

@@ -25,6 +25,9 @@
+
+ {{> share shareText='Share this post'}} +
{{> footer }} @@ -52,5 +55,19 @@ } +