aboutsummaryrefslogtreecommitdiff
path: root/layouts/partials
diff options
context:
space:
mode:
authorNicholas Johnson <mail@nicholasjohnson.ch>2025-02-06 00:00:00 +0000
committerNicholas Johnson <mail@nicholasjohnson.ch>2025-02-06 00:00:00 +0000
commit6ac2fc6523a8038c2b7acd268d047c3e33f5939578c1ff2e7fbdd526ba422335 (patch)
tree295c217220e8e35179ca57fe04dc16d62ca734d0f12fe2101c19ee3cd9b9c746 /layouts/partials
parent1499480874751f9d55f29e2be9b94d571ae1577e2201856a2461383d73553aa6 (diff)
downloadhugo-theme-journal-6ac2fc6523a8038c2b7acd268d047c3e33f5939578c1ff2e7fbdd526ba422335.tar.gz
hugo-theme-journal-6ac2fc6523a8038c2b7acd268d047c3e33f5939578c1ff2e7fbdd526ba422335.zip
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.
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/metadata.gmi2
-rw-r--r--layouts/partials/metadata.html2
-rw-r--r--layouts/partials/pageinfo.gmi11
-rw-r--r--layouts/partials/pageinfo.html13
4 files changed, 24 insertions, 4 deletions
diff --git a/layouts/partials/metadata.gmi b/layouts/partials/metadata.gmi
index 04749d9..48d3db4 100644
--- a/layouts/partials/metadata.gmi
+++ b/layouts/partials/metadata.gmi
@@ -1,2 +1,2 @@
{{ partial "pageinfo.gmi" . }}
-=> {{ .RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ .Title }} \ No newline at end of file
+=> {{ .RelPermalink | strings.TrimSuffix "index.gmi" }} {{ emojify ":link:" }} {{ .Title }} \ No newline at end of file
diff --git a/layouts/partials/metadata.html b/layouts/partials/metadata.html
index 4158ee5..ed091b8 100644
--- a/layouts/partials/metadata.html
+++ b/layouts/partials/metadata.html
@@ -1,6 +1,6 @@
<article>
<header>
<p>{{ partial "pageinfo.html" . }}<br>
- {{ emojify ":link:" }} <a class="link link--internal" href="{{ .RelPermalink }}" rel="noreferrer">{{ .Title }}</a></p>
+ {{ emojify ":link:" }}&nbsp;<a class="link link--internal" href="{{ .RelPermalink }}" rel="noreferrer">{{ .Title }}</a></p>
</header>
</article> \ No newline at end of file
diff --git a/layouts/partials/pageinfo.gmi b/layouts/partials/pageinfo.gmi
index 0e2d051..adde0c0 100644
--- a/layouts/partials/pageinfo.gmi
+++ b/layouts/partials/pageinfo.gmi
@@ -1,2 +1,11 @@
{{ $dateFormat := .Site.Params.dateFormat | default ":date_long" -}}
-{{ emojify ":calendar:" }} {{ .Page.PublishDate | time.Format $dateFormat }} | {{ emojify ":stopwatch:" }} {{ i18n "readingTime" .ReadingTime }}{{ 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
+
+{{ $nonBreakingPublishDate := .Page.PublishDate | time.Format $dateFormat -}}
+{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate " " " " -}}
+{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate "-" "‑" -}}
+
+{{ $nonBreakingReadingTime := i18n "readingTime" .ReadingTime -}}
+{{ $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
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:" }} <time {{ printf "datetime=%q" (.Page.PublishDate | time.Format "2006-01-02T15:04:05-0700") | safeHTMLAttr }}>{{ .Page.PublishDate | time.Format $dateFormat }}</time> | {{ emojify ":stopwatch:" }} <time datetime="PT{{ .ReadingTime }}M">{{ i18n "readingTime" .ReadingTime }}</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 }}
+
+{{/* 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 " " "&nbsp;" -}}
+{{ $nonBreakingPublishDate = replace $nonBreakingPublishDate "-" "&#8209;" -}}
+
+{{/* user-overridable parameter $readingTime is escaped pre-insertion so that HTML entities can be inserted */ -}}
+{{ $nonBreakingReadingTime := i18n "readingTime" .ReadingTime | htmlEscape -}}
+{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " "&nbsp;" -}}
+{{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "&#8209;" -}}
+
+{{ emojify ":calendar:" }}&nbsp;<time {{ printf "datetime=%q" (.Page.PublishDate | time.Format "2006-01-02T15:04:05-0700") | safeHTMLAttr }}>{{ $nonBreakingPublishDate | safeHTML }}</time> | {{ emojify ":stopwatch:" }}&nbsp;<time datetime="PT{{ .ReadingTime }}M">{{ $nonBreakingReadingTime | safeHTML }}</time>{{ if (.Param (lower (i18n "tags"))) }} | {{ emojify ":label:" }}&nbsp;{{ 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 }}