From 6ac2fc6523a8038c2b7acd268d047c3e33f5939578c1ff2e7fbdd526ba422335 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Thu, 6 Feb 2025 00:00:00 +0000 Subject: Add non-breaking spaces to improve text flow The spaces directly following emojis must be non-breaking because having emojis alone on their own line is ugly and visually confusing. The spaces within pageinfo "segments" must be non-breaking because splitting dates and read times across multiple lines is ugly and visually confusing. --- layouts/partials/pageinfo.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'layouts/partials/pageinfo.html') diff --git a/layouts/partials/pageinfo.html b/layouts/partials/pageinfo.html index c002530..8879d5e 100644 --- a/layouts/partials/pageinfo.html +++ b/layouts/partials/pageinfo.html @@ -1,2 +1,13 @@ {{ $dateFormat := .Site.Params.dateFormat | default ":date_long" -}} -{{ emojify ":calendar:" }} | {{ emojify ":stopwatch:" }} {{ if (.Param (lower (i18n "tags"))) }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := (.Param (lower (i18n "tags"))) }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} + +{{/* user-overridable parameter $dateFormat is escaped pre-insertion so that HTML entities can be inserted */ -}} +{{ $nonBreakingPublishDate := .Page.PublishDate | time.Format $dateFormat | htmlEscape -}} +{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate " " " " -}} +{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate "-" "‑" -}} + +{{/* user-overridable parameter $readingTime is escaped pre-insertion so that HTML entities can be inserted */ -}} +{{ $nonBreakingReadingTime := i18n "readingTime" .ReadingTime | htmlEscape -}} +{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} +{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} + +{{ emojify ":calendar:" }}  | {{ emojify ":stopwatch:" }} {{ if (.Param (lower (i18n "tags"))) }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := (.Param (lower (i18n "tags"))) }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} -- cgit v1.2.3