From 170165d84510bb3fec4991eab064c9e69337bb64 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Wed, 19 Oct 2022 14:30:41 -0700 Subject: [PATCH] Remove extra canonical URL from post lists I used Scratch to sort of pass variables to a partial, like a global variable. Ugly but that's the price we pay for Hugo's concurrency and caching. --- layouts/_default/list.html | 3 ++- layouts/partials/post-meta.html | 2 +- layouts/shortcodes/indieweb-author.html | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 199c411..e27e092 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -23,7 +23,8 @@ {{ .Title }} - {{- partial "post-meta.html" .}} + {{- .Scratch.Set "noCanonical" true -}} + {{- partial "post-meta.html" . }} {{- if eq .Section "notes" }}
{{- if .Params.replyURI -}} diff --git a/layouts/partials/post-meta.html b/layouts/partials/post-meta.html index a702aeb..4cf8cc1 100644 --- a/layouts/partials/post-meta.html +++ b/layouts/partials/post-meta.html @@ -9,7 +9,7 @@ {{- $logURL = $logURL | strings.ReplaceRE `\.md` `.gmi` -}} {{- end -}}

-{{- $action }} {{ .Date.Format "2006-01-02" }} by {{ partial "indieweb-author.html" -}} on his {{- with .OutputFormats.Get "gemtext" -}}{{- printf " " -}}and Gemini capsule{{- end -}}. +{{- $action }} {{ .Date.Format "2006-01-02" }} by {{ partial "indieweb-author.html" -}}{{ if not (.Scratch.Get "noCanonical") }} on his {{- with .OutputFormats.Get "gemtext" -}}{{- printf " " -}}and Gemini capsule{{ end }}{{- end -}}. {{- if gt (sub .Lastmod.Unix .Date.Unix) 900 -}}
Last updated . Changelog. diff --git a/layouts/shortcodes/indieweb-author.html b/layouts/shortcodes/indieweb-author.html index cdd2536..3aff16a 100644 --- a/layouts/shortcodes/indieweb-author.html +++ b/layouts/shortcodes/indieweb-author.html @@ -24,4 +24,4 @@ - +{{- /* no line break */ -}}