From cde5d340bd4006deb9bff34fa68aa36969a0e67a Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 19 Feb 2024 22:19:19 -0500 Subject: [PATCH] Adds social media meta tags and new param for featured images --- README.md | 8 ++++++++ layouts/partials/site_header.html | 14 ++++++++++++-- static/js/weblog.js | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8fcf1b4..6571b62 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,14 @@ These posts are rendered slightly different with an → to signify that it is re ![External URL](https://github.com/jnjosh/internet-weblog/raw/master/images/linkpost.png) +#### Specifying a featured image for social media + +Sometimes you want to feature an image as your featured image that will display when linking your post in social media. This can be done by including the `feature` parameter on your individual post. Note you don't need to put the URL, just the path to the image without a leading `/` + +``` +feature: "assets/posts/20240219/image.jpg" +``` + ### Variables | Variable | What value? | Required | diff --git a/layouts/partials/site_header.html b/layouts/partials/site_header.html index 9d1fb05..392441f 100644 --- a/layouts/partials/site_header.html +++ b/layouts/partials/site_header.html @@ -6,17 +6,27 @@ - {{ hugo.Generator }} + {{ $siteTitle := .Site.Title }} {{ $title := $siteTitle }}{{ if .IsPage }}{{ $title = .Title }} + + + {{ if .Param "feature" }}{{ end }} + + + + + {{ end }} + {{ hugo.Generator }} {{ $.Scratch.Add "title" .Site.Title }} {{ with .Title }}{{ if ne . ($.Scratch.Get "title") }}{{ . }} · {{ end }}{{ end }}@{{ .Site.Author.handle }}’s {{ .Site.Title }} + {{ partial "custom_stylesheets.html" . }} {{ if .Site.Params.rssenabled }} - + {{ end }} diff --git a/static/js/weblog.js b/static/js/weblog.js index c668f0d..f5e2c5b 100644 --- a/static/js/weblog.js +++ b/static/js/weblog.js @@ -17,7 +17,7 @@ iweblog.application = function() { cnt++; }); - $('#photos').html(htmlString); + $('#photos').html(htmlString); $('#photos').lightGallery(); }