theme: merge title generation into one partial #825

This commit is contained in:
Sören Weber 2024-04-07 22:13:52 +02:00
parent b8eb8c3bbb
commit 07f5acc184
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
7 changed files with 19 additions and 20 deletions

View file

@ -4,7 +4,7 @@
<html lang="{{ .Page.Language.LanguageCode | default "en" }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}">
<head>
{{- partial "meta.html" . }}
{{- $title := partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true) }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}
<title>{{ $title }}</title>
<base href="{{ .Site.BaseURL }}">
{{- partialCached "favicon.html" . }}

View file

@ -31,7 +31,7 @@
{{- range $i, $e := $breadcrumbReversed }}
{{- $to := $e }}
{{- $depth = add $depth 1 }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" $to "useLinkTitle" true) }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" $to "linkTitle" true) }}
{{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}
{{- $isPage := eq $url $pageurl }}
{{- $isLast := eq $url $lasturl }}

View file

@ -16,7 +16,7 @@
{{- partial "meta.html" . }}
{{- $page := . }}
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
{{- $title := partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true "format" $format "outputFormat" $outputFormat) }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) }}
<title>{{ $title }}</title>
{{- if .IsTranslated -}}

View file

@ -10,7 +10,7 @@
{{- with or site.Title site.Params.title | plainify }}
<meta property="og:site_name" content="{{ . }}">
{{- end }}
<meta property="og:title" content="{{ partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true "format" $format "outputFormat" $outputFormat) | plainify }}">
<meta property="og:title" content="{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) | plainify }}">
{{- with or .Description .Summary site.Params.description | plainify }}
<meta property="og:description" content="{{ . }}">
@ -23,7 +23,7 @@
{{- if .IsPage }}
<meta property="og:type" content="article">
{{- with .FirstSection }}
<meta property="article:section" content="{{ partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true "format" $format "outputFormat" $outputFormat) | plainify }}">
<meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true "format" $format "outputFormat" $outputFormat) | plainify }}">
{{- end }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" }}
{{- with .PublishDate }}

View file

@ -1,11 +0,0 @@
{{- $title := partial "pageHelper/title.hugo" . }}
{{- with .page }}
{{- if and $title site.Title (not (eq $title site.Title)) }}
{{- if $.invert }}
{{- $title = printf "%s %s %s" $title (default "::" site.Params.titleSeparator) site.Title }}
{{- else }}
{{- $title = printf "%s %s %s" site.Title (default "::" site.Params.titleSeparator) $title }}
{{- end }}
{{- end }}
{{- end }}
{{- return $title }}

View file

@ -6,7 +6,7 @@
{{- $format := $.format | default (partial "get-format.hugo" .) }}
{{- $outputFormat := $.outputFormat | default (partial "output-format.hugo" (dict "page" . "format" $format)) }}
{{- $title = .Title }}
{{- if $.useLinkTitle }}
{{- if $.linkTitle }}
{{- $title = or $.page.Params.menuTitle $.page.LinkTitle $title }}
{{- end }}
@ -20,13 +20,23 @@
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $taxonomy_title := default (default $taxonomy_page.Data.Singular (i18n $taxonomy_page.Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $term_title := default (humanize .Data.Term | strings.Title) .Title }}
{{- if $.useLinkTitle }}
{{- if $.linkTitle }}
{{- $title = printf "%s" $term_title }}
{{- else if $.invert }}
{{- else if $.reverse }}
{{- $title = printf "%s %s %s" $term_title (default "::" .Site.Params.titleSeparator) $taxonomy_title }}
{{- else }}
{{- $title = printf "%s %s %s" $taxonomy_title (default "::" .Site.Params.titleSeparator) $term_title }}
{{- end }}
{{- end }}
{{- if $.fullyQualified }}
{{- if and $title site.Title (not (eq $title site.Title)) }}
{{- if $.reverse }}
{{- $title = printf "%s %s %s" $title (default "::" site.Params.titleSeparator) site.Title }}
{{- else }}
{{- $title = printf "%s %s %s" site.Title (default "::" site.Params.titleSeparator) $title }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- return $title }}

View file

@ -6,7 +6,7 @@
{{- else }}
<meta name="twitter:card" content="summary">
{{- end }}
<meta name="twitter:title" content="{{ partial "pageHelper/fullTitle.hugo" (dict "page" . "invert" true) }}">
<meta name="twitter:title" content="{{ partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}">
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
{{- $twitterSite := "" }}