theme: misc stuff from optimization finds #685

This commit is contained in:
Sören Weber 2024-07-21 23:40:57 +02:00
parent fe9d605d57
commit be860ccbf7
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
9 changed files with 29 additions and 20 deletions

View file

@ -42,8 +42,14 @@
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }}
{{- end }}
{{- range $pages }}
{{- $visible := true }}
{{- $relearnIsHiddenFrom := index ($page.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
{{- if and .Permalink .Title (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableSeoHiddenPages true) ) }}
{{- if or (eq .Kind "taxonomy") (eq .Kind "term") }}
{{- $visible = and .Title .Permalink (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableTagHiddenPages true) ) }}
{{- else }}
{{- $visible = and .Title .Permalink (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableSeoHiddenPages true) ) }}
{{- end }}
{{- if $visible }}
<item>
<title>{{ partial "pageHelper/title.hugo" (dict "page" . "format" $format "outputFormat" $outputFormat) }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>

View file

@ -31,7 +31,7 @@
{{- end }}
{{- end }}
{{- if not (and .Title (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) ) ) }}
{{- else }}
{{- range .AlternativeOutputFormats }}
{{- if eq .Rel "canonical" }}

View file

@ -143,10 +143,10 @@
{{- $subHidden := and $relearnIsSubHiddenFrom (not $.showhidden) (not $isSelfSub) (not $isAncestorSub) }}
{{- $numberOfVisibleChildren = add $numberOfVisibleChildren (int (not $subHidden)) }}
{{- end }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" . "linkTitle" true) }}
{{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
{{- safeHTML .Params.head }}
{{- if $numberOfVisibleChildren }}
{{- $title := or .LinkTitle .Title }}
{{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
{{- $isCollapsible := or (.Params.collapsibleMenu | default .Site.Params.collapsibleMenu) (not $url) }}
{{- $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }}
{{- $pageHash := md5 .Page }}
@ -159,8 +159,6 @@
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- end }}</ul></li>
{{- else }}
{{- $title := or .LinkTitle .Title }}
{{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}
<li data-nav-id="{{ $url }}" class="{{if $isActive }}active{{end}}">{{ if $url }}<a class="padding" href="{{ $url }}">{{ else }}<span class="padding">{{ end }}
{{- partial "menu-pre.html" . }}{{ $title }}{{ partial "menu-post.html" . }}
{{- if $url }}{{ if $showvisitedlinks }}<i class="fa-fw fas fa-check read-icon"></i>{{ end }}</a>{{ else }}</span>{{ end }}</li>

View file

@ -10,7 +10,7 @@
{{- $ver := printf "<meta name=\"generator\" content=\"%s %s\">" "Relearn" $ver }}
{{ $ver | safeHTML }}
{{- end }}
{{- if not (and .Title (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">
{{- end }}
<meta name="description" content="{{ with or .Description .Summary | plainify | htmlUnescape | chomp }}{{ . }}{{ end }}">

View file

@ -14,8 +14,13 @@
{{- $currentNode.Store.Set $has true }}
{{- end }}
{{- end }}
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false }}
{{- if not ($currentNode.Scratch.Get "relearnIsSelfFound") }}
{{- if not $currentNode.IsHome }}
{{- $currentNode.Scratch.Set "relearnPrevPage" .Site.Home }}
{{- end }}
{{- end }}
{{- define "relearn-structure" }}
{{- $currentNode := .currentnode }}
{{- $isSelf := eq $currentNode .node }}

View file

@ -1 +0,0 @@
{{- return (or (not .Title) .Params.hidden) }}

View file

@ -5,7 +5,6 @@
{{- $by = "" }}
{{- end }}
{{- $by = $by | default $page.Params.ordersectionsby | default $page.Site.Params.ordersectionsby | default "weight" }}
{{- $hidden := .hidden }}
{{- $pages := slice }}

View file

@ -3,18 +3,19 @@
{{- if .Params.menuTitle }}
{{- warnf "%q: UNSUPPORTED frontmatter 'menutitle' found, use 'linktitle' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#600" $.File.Filename }}
{{- end }}
{{- $format := $.format | default (partial "get-format.hugo" .) }}
{{- $outputFormat := $.outputFormat | default (partial "output-format.hugo" (dict "page" . "format" $format)) }}
{{- $siteTitle := site.Title }}
{{- $title = .Title }}
{{- if $.linkTitle }}
{{- $title = or $.page.LinkTitle $title }}
{{- $title = or .LinkTitle $title }}
{{- end }}
{{- if eq .Kind "home" }}
{{- $title = $title | default $siteTitle }}
{{- $format := $.format | default (partial "get-format.hugo" .) }}
{{- $outputFormat := $.outputFormat | default (partial "output-format.hugo" (dict "page" . "format" $format)) }}
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "home" }}
{{- $title = or $title $siteTitle }}
{{- end }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Params.Title }}
{{- else if eq .Kind "term" }}

View file

@ -10,16 +10,17 @@
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
{{- $startarrow = "🡒" }}
{{- end }}
{{- $prev := .Scratch.Get "relearnPrevPage" | default .Site.Home }}
{{- $prev := .Scratch.Get "relearnPrevPage" }}
{{- if eq $outputFormat "searchpage" }}
{{- $outputFormat = "html" }}
{{- else if eq .Page.Kind "home" }}
{{- $prev = "" }}
{{- $prev = .Site.Home }}
{{- else if eq .Page.Kind "term" }}
{{- /* go to previous term page or taxonomy page if it is the first term */}}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" $taxonomy_page $taxonomy_page }}
{{- $prev = partial "partials/pageHelper/prev.html" (dict "collection" $pages "item" .) | default $taxonomy_page }}
{{- else if eq .Page.Kind "taxonomy" }}
{{- $prev = .Site.Home }}
{{- end }}
{{- $prevTitle := partial "pageHelper/title.hugo" (dict "page" $prev "format" $format "outputFormat" $outputFormat) }}
{{- partial "topbar/func/button.html" (dict