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" .)) "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .))
"title" (partial "pageHelper/title.hugo" (dict "page" .) | plainify) "title" (partial "pageHelper/title.hugo" (dict "page" .) | plainify)
"tags" $tags "tags" $tags
"breadcrumb" (partial "breadcrumbs.html" (dict "page" . "dirOnly" true) | plainify | htmlUnescape | chomp) "breadcrumb" (trim (partial "breadcrumbs.html" (dict "page" . "dirOnly" true) | plainify | htmlUnescape) "\n\r\t ")
"description" (or .Description .Summary | plainify | htmlUnescape | chomp) "description" (trim (or .Description .Summary | plainify | htmlUnescape) "\n\r\t " )
"content" (.Plain | htmlUnescape | chomp) "content" (trim (.Plain | htmlUnescape) "\n\r\t ")
) }} ) }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}

View File

@ -29,7 +29,7 @@
<channel> <channel>
<title>{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}</title> <title>{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link> <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> <generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }} <language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ 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> <pubDate>{{ (or .PublishDate .Date).Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }} {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</guid> <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> </item>
{{- end }} {{- end }}
{{- end }} {{- end }}

View File

@ -22,7 +22,7 @@
{{- /* display pages of a term */}} {{- /* display pages of a term */}}
{{- $breadcrumb := "" }} {{- $breadcrumb := "" }}
{{- if (ne .Page.Site.Params.disableTermBreadcrumbs true) }} {{- 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 }} {{- end }}
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ .Title }}</a>{{ with $breadcrumb }}<div class="breadcrumbs highlightable" title="{{ . }}">{{ . }}</div>{{ end }}</li> <li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ .Title }}</a>{{ with $breadcrumb }}<div class="breadcrumbs highlightable" title="{{ . }}">{{ . }}</div>{{ end }}</li>
{{- $lastCapital = $capital }} {{- $lastCapital = $capital }}

View File

@ -13,7 +13,7 @@
{{- if not (and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }} {{- if not (and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }}
<meta name="robots" content="noindex, nofollow, noarchive, noimageindex"> <meta name="robots" content="noindex, nofollow, noarchive, noimageindex">
{{- end }} {{- 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" . }} {{- $authorName := partialCached "authorname.hugo" . }}
<meta name="author" content="{{ $authorName }}"> <meta name="author" content="{{ $authorName }}">
{{- partial "twitter_cards.html" . }} {{- partial "twitter_cards.html" . }}

View File

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

View File

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

View File

@ -9,7 +9,7 @@
{{- $currentDisableToc := .Params.disableToc | default $defaultDisableToc }} {{- $currentDisableToc := .Params.disableToc | default $defaultDisableToc }}
{{- if and (eq $outputFormat "html") (not $currentDisableToc) }} {{- if and (eq $outputFormat "html") (not $currentDisableToc) }}
{{- $content := partial "toc-class.html" . }} {{- $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 }} {{- if not $hascontent }}
{{- $content = " " }} {{- $content = " " }}
{{- end }} {{- end }}

View File

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