From 110c5124bdf0046864503714daa2c6d37d0c7a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Tue, 27 Aug 2024 15:35:48 +0200 Subject: [PATCH] toc: don't show toc button if empty #893 --- layouts/_default/index.search.js | 6 +++--- layouts/_default/rss.xml | 4 ++-- layouts/_default/term.html | 2 +- layouts/partials/meta.html | 2 +- layouts/partials/opengraph.html | 2 +- layouts/partials/schema.html | 2 +- layouts/partials/topbar/button/toc.html | 2 +- layouts/partials/twitter_cards.html | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/layouts/_default/index.search.js b/layouts/_default/index.search.js index 6a7291296c..243a4c70c3 100644 --- a/layouts/_default/index.search.js +++ b/layouts/_default/index.search.js @@ -10,9 +10,9 @@ "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) "title" (partial "pageHelper/title.hugo" (dict "page" .) | plainify) "tags" $tags - "breadcrumb" (partial "breadcrumbs.html" (dict "page" . "dirOnly" true) | plainify | htmlUnescape | chomp) - "description" (or .Description .Summary | plainify | htmlUnescape | chomp) - "content" (.Plain | htmlUnescape | chomp) + "breadcrumb" (trim (partial "breadcrumbs.html" (dict "page" . "dirOnly" true) | plainify | htmlUnescape) "\n\r\t ") + "description" (trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " ) + "content" (trim (.Plain | htmlUnescape) "\n\r\t ") ) }} {{- end }} {{- end -}} diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 1a7a24805f..518531e4d1 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -29,7 +29,7 @@ {{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }} {{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }} - {{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }} + {{ trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " | transform.XMLEscape | safeHTML }} Hugo {{ site.Language.LanguageCode }}{{ with $authorEmail }} {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with $authorEmail }} @@ -54,7 +54,7 @@ {{ (or .PublishDate .Date).Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} {{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }} - {{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }} + {{ trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " | transform.XMLEscape | safeHTML }} {{- end }} {{- end }} diff --git a/layouts/_default/term.html b/layouts/_default/term.html index b42e1c04dc..7ddd7dff6d 100644 --- a/layouts/_default/term.html +++ b/layouts/_default/term.html @@ -22,7 +22,7 @@ {{- /* display pages of a term */}} {{- $breadcrumb := "" }} {{- if (ne .Page.Site.Params.disableTermBreadcrumbs true) }} - {{- $breadcrumb = partial "breadcrumbs.html" (dict "page" .Page "dirOnly" true) | plainify | htmlUnescape | chomp }} + {{- $breadcrumb = trim (partial "breadcrumbs.html" (dict "page" .Page "dirOnly" true) | plainify | htmlUnescape) "\n\r\t " }} {{- end }}
  • {{ .Title }}{{ with $breadcrumb }}{{ end }}
  • {{- $lastCapital = $capital }} diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index 937b6ad79f..552c4e84c1 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -13,7 +13,7 @@ {{- if not (and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }} {{- end }} - + {{- $authorName := partialCached "authorname.hugo" . }} {{- partial "twitter_cards.html" . }} diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index 1ee5b33df9..db4a4eec09 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -17,7 +17,7 @@ {{- end }} -{{- with or .Description .Summary | plainify | htmlUnescape | chomp }} +{{- with trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " }} {{- end }} diff --git a/layouts/partials/schema.html b/layouts/partials/schema.html index ecf7116971..18c54d7733 100644 --- a/layouts/partials/schema.html +++ b/layouts/partials/schema.html @@ -3,7 +3,7 @@ {{- end }} -{{- with or .Description .Summary | plainify | htmlUnescape | chomp }} +{{- with trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " }} {{- end }} diff --git a/layouts/partials/topbar/button/toc.html b/layouts/partials/topbar/button/toc.html index 6b8a8beae3..d7d8dcf708 100644 --- a/layouts/partials/topbar/button/toc.html +++ b/layouts/partials/topbar/button/toc.html @@ -9,7 +9,7 @@ {{- $currentDisableToc := .Params.disableToc | default $defaultDisableToc }} {{- if and (eq $outputFormat "html") (not $currentDisableToc) }} {{- $content := partial "toc-class.html" . }} - {{- $hascontent := not (eq 0 (int (len ($content | plainify | chomp)))) }} + {{- $hascontent := not (eq 0 (int (len (trim ($content | plainify) "\n\r\t ")))) }} {{- if not $hascontent }} {{- $content = " " }} {{- end }} diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html index cc640f123d..3dc4036368 100644 --- a/layouts/partials/twitter_cards.html +++ b/layouts/partials/twitter_cards.html @@ -11,7 +11,7 @@ {{- end }} -{{- with or .Description .Summary | plainify | htmlUnescape | chomp }} +{{- with trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " }} {{- end }}