diff options
author | Nicholas Johnson <mail@nicholasjohnson.ch> | 2025-02-06 00:00:00 +0000 |
---|---|---|
committer | Nicholas Johnson <mail@nicholasjohnson.ch> | 2025-02-06 00:00:00 +0000 |
commit | e17004fc6714b7d214aa61f43fa75f1fc9bc0ec00804e0525452cb287a81958a (patch) | |
tree | 3228b770bc360cfaed9d1fe4867c0b09e7eb3cabd6fe992ab193dd1f43bcb416 | |
parent | 5844d48eefde01b72463dc83a091d18e06c5e37148e611b342e2a42fb2476c70 (diff) | |
download | hugo-theme-journal-e17004fc6714b7d214aa61f43fa75f1fc9bc0ec00804e0525452cb287a81958a.tar.gz hugo-theme-journal-e17004fc6714b7d214aa61f43fa75f1fc9bc0ec00804e0525452cb287a81958a.zip |
Add non-breaking spaces within entry tag names
The spaces in tag names must be non-breaking because tag names
split across multiple lines are visually indistinguishable from distinct
tags.
-rw-r--r-- | layouts/partials/pageinfo.gmi | 9 | ||||
-rw-r--r-- | layouts/partials/pageinfo.html | 12 |
2 files changed, 19 insertions, 2 deletions
diff --git a/layouts/partials/pageinfo.gmi b/layouts/partials/pageinfo.gmi index adde0c0..9993d93 100644 --- a/layouts/partials/pageinfo.gmi +++ b/layouts/partials/pageinfo.gmi @@ -8,4 +8,11 @@ {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} -{{ emojify ":calendar:" }} {{ $nonBreakingPublishDate }} | {{ emojify ":stopwatch:" }} {{ $nonBreakingReadingTime }}{{ if (.Param (lower (i18n "tags"))) }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := (.Param (lower (i18n "tags"))) }}{{ if $key }}, {{ end }}{{ $val }}{{ end }}
\ No newline at end of file +{{ $nonBreakingTags := slice -}} +{{ range .Param (lower (i18n "tags")) -}} + {{ $nonBreakingTag := replace . " " " " -}} + {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} + {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} +{{ end -}} + +{{ emojify ":calendar:" }} {{ $nonBreakingPublishDate }} | {{ emojify ":stopwatch:" }} {{ $nonBreakingReadingTime }}{{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }}
\ No newline at end of file diff --git a/layouts/partials/pageinfo.html b/layouts/partials/pageinfo.html index 8917ea7..3ca8fe9 100644 --- a/layouts/partials/pageinfo.html +++ b/layouts/partials/pageinfo.html @@ -10,4 +10,14 @@ {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} -{{ emojify ":calendar:" }} <time {{ printf "datetime=%q" (.Page.PublishDate | time.Format "2006-01-02T15:04:05-0700") | safeHTMLAttr }}>{{ $nonBreakingPublishDate | safeHTML }}</time> | {{ emojify ":stopwatch:" }} <time datetime="PT{{ .ReadingTime }}M">{{ $nonBreakingReadingTime | safeHTML }}</time>{{ if (.Param (lower (i18n "tags"))) }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := (.Param (lower (i18n "tags"))) }}{{ if $key }} {{ end }}<a class="link link--internal" href='{{ relLangURL (lower (i18n "tags")) }}/{{ . | urlize }}/' rel="noreferrer">{{ $val }}</a>{{ end }} +{{ $breakingTags := .Param (lower (i18n "tags")) -}} +{{ $nonBreakingTags := slice -}} +{{ range $breakingTags -}} + {{/* user-defined tags are escaped pre-insertion so that HTML entities can be inserted */ -}} + {{ $nonBreakingTag := htmlEscape . -}} + {{ $nonBreakingTag = replace $nonBreakingTag " " " " -}} + {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} + {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} +{{ end -}} + +{{ emojify ":calendar:" }} <time {{ printf "datetime=%q" (.Page.PublishDate | time.Format "2006-01-02T15:04:05-0700") | safeHTMLAttr }}>{{ $nonBreakingPublishDate | safeHTML }}</time> | {{ emojify ":stopwatch:" }} <time datetime="PT{{ .ReadingTime }}M">{{ $nonBreakingReadingTime | safeHTML }}</time>{{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }} {{ end }}<a class="link link--internal" href='{{ relLangURL (lower (i18n "tags")) }}/{{ index $breakingTags $key | urlize }}/' rel="noreferrer">{{ $val | safeHTML }}</a>{{ end }} |