Skip to content

Commit

Permalink
toc: don't show toc button if empty #893
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Aug 27, 2024
1 parent 3aa35c1 commit 110c512
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions layouts/_default/index.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2 id="{{ $capital | plainify | anchorize }}">{{ $capital }}</h2>
{{- /* 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 }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" . }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/topbar/button/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/twitter_cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down

0 comments on commit 110c512

Please sign in to comment.