toc: don't show toc button if empty #893

This commit is contained in:
Sören Weber 2024-08-27 15:35:48 +02:00
parent 3aa35c18db
commit 110c5124bd
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
8 changed files with 11 additions and 11 deletions

View file

@ -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 -}}

View file

@ -29,7 +29,7 @@
<channel>
<title>{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
<description>{{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }}</description>
<description>{{ trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " | transform.XMLEscape | safeHTML }}</description>
<generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
@ -54,7 +54,7 @@
<pubDate>{{ (or .PublishDate .Date).Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</guid>
<description>{{ or .Description .Summary | plainify | htmlUnescape | chomp | transform.XMLEscape | safeHTML }}</description>
<description>{{ trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " | transform.XMLEscape | safeHTML }}</description>
</item>
{{- end }}
{{- end }}

View file

@ -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 }}
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ .Title }}</a>{{ with $breadcrumb }}<div class="breadcrumbs highlightable" title="{{ . }}">{{ . }}</div>{{ end }}</li>
{{- $lastCapital = $capital }}

View file

@ -13,7 +13,7 @@
{{- if not (and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }}
<meta name="robots" content="noindex, nofollow, noarchive, noimageindex">
{{- end }}
<meta name="description" content="{{ with or .Description .Summary | plainify | htmlUnescape | chomp }}{{ . }}{{ end }}">
<meta name="description" content="{{ with trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " }}{{ . }}{{ end }}">
{{- $authorName := partialCached "authorname.hugo" . }}
<meta name="author" content="{{ $authorName }}">
{{- partial "twitter_cards.html" . }}

View file

@ -17,7 +17,7 @@
<meta property="og:title" content="{{ . }}">
{{- end }}
{{- with or .Description .Summary | plainify | htmlUnescape | chomp }}
{{- with trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " }}
<meta property="og:description" content="{{ . }}">
{{- end }}

View file

@ -3,7 +3,7 @@
<meta itemprop="name" content="{{ . }}">
{{- end }}
{{- with or .Description .Summary | plainify | htmlUnescape | chomp }}
{{- with trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " }}
<meta itemprop="description" content="{{ . }}">
{{- end }}

View file

@ -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 }}

View file

@ -11,7 +11,7 @@
<meta name="twitter:title" content="{{ . }}">
{{- end }}
{{- with or .Description .Summary | plainify | htmlUnescape | chomp }}
{{- with trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " }}
<meta name="twitter:description" content="{{ . }}">
{{- end }}