theme: sync to Hugo's implementation #841

This commit is contained in:
Sören Weber 2024-04-22 22:43:59 +02:00
parent f4df3a06ad
commit af29d89995
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
7 changed files with 32 additions and 44 deletions

View file

@ -1,3 +1,4 @@
{{- /* based on Hugo 0.125.3 rss.xml */}}
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
{{- $authorEmail := "" }}
@ -29,15 +30,15 @@
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{ . }}</language>{{end}}{{ with $authorEmail }}
<generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "rss" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }}
{{- end -}}
{{- end }}
{{- range $pages }}
{{- $relearnIsHiddenFrom := index ($page.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
{{- if and .Permalink .Title (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableSeoHiddenPages true) ) }}

View file

@ -1,8 +1,9 @@
{{- /* based on Hugo 0.125.3 sitemap.xml */}}
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{- range where .Pages "Sitemap.Disable" "ne" true }}
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
<url>
<loc>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
@ -11,6 +12,6 @@
<xhtml:link rel="alternate" hreflang="x-default" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />{{ end }}
<xhtml:link rel="alternate" hreflang="{{ .Language.LanguageCode }}" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}" />{{ end }}{{ end }}
</url>
{{- end -}}
{{- end -}}
{{- end }}
</urlset>

View file

@ -1,3 +1,4 @@
{{- /* based on Hugo 0.125.3 alias.html */}}
<!DOCTYPE html>
<html>
<head>
@ -22,9 +23,9 @@
<meta charset="utf-8">
<meta name="robots" content="noindex">
<meta http-equiv="refresh" content="0; url={{ $url }}">
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
{{- $link := "<link href=\"%s\" rel=\"%s\">" }}
<title>{{ $url }}</title>
{{ (printf $link $url "canonical" "text/html" ($url | htmlEscape)) | safeHTML }}
{{ (printf $link $url "canonical" ($url | htmlEscape)) | safeHTML }}
</head>
</html>

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.0 _internal/opengraph.html but with modified title */}}
{{- /* based on Hugo 0.125.3 opengraph.html */}}
{{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $basename := "index" }}
@ -74,23 +74,14 @@
{{- end }}
{{- end }}
{{- $facebookAdmin := "" }}
{{- with site.Params.social.facebook_admin }}
{{- $facebookAdmin = . }}
{{- else }}
{{- with site.Social.facebook_admin }}
{{- $facebookAdmin = . }}
{{- $hugoVersion := "0.120.0" }}
{{- if ge hugo.Version $hugoVersion }}
{{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }}
{{- with site.Params.social }}
{{- if reflect.IsMap . }}
{{- with .facebook_app_id }}
<meta property="fb:app_id" content="{{ . }}">
{{- else }}
{{- with .facebook_admin }}
<meta property="fb:admins" content="{{ . }}">
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- with $facebookApp }}
<meta property="fb:app_id" content="{{ . }}">
{{- else }}
{{- with $facebookAdmin }}
<meta property="fb:admins" content="{{ . }}">
{{- end }}
{{- end }}

View file

@ -1,3 +1,4 @@
{{- /* based on Hugo 0.125.3 render-image.html */}}
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
@ -77,7 +78,7 @@
{{- $classes = $classes | append $c }}
{{- end }}
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }}
{{- $attributes = merge $attributes (dict "alt" $alt "src" $url "title" $title) }}
{{- $attributes = merge $attributes (dict "alt" $alt "src" $url "title" ($title | transform.HTMLEscape)) }}
{{- if $effects.lazy }}
{{- $attributes = merge $attributes (dict "loading" "lazy") }}
{{- end }}

View file

@ -1,3 +1,4 @@
{{- /* based on Hugo 0.125.3 render-link.html */}}
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
@ -10,7 +11,7 @@
{{- $attributes := dict }}
{{- $title := .title | default "" }}
{{- $title = trim $title " " }}
{{- $attributes = $attributes | merge (dict "title" $title) }}
{{- $attributes = $attributes | merge (dict "title" ($title | transform.HTMLEscape)) }}
{{- $content := .content }}
{{- $target := .target | default "" }}
{{- $u := urls.Parse $url }}

View file

@ -1,4 +1,4 @@
{{- /* based on Hugo 0.125.0 _internal/twitter_cardss.html but with modified title */}}
{{- /* based on Hugo 0.125.3 twitter_cards.html */}}
{{- $images := partial "_funcs/get-page-images" . }}
{{- with index $images 0 }}
<meta name="twitter:card" content="summary_large_image">
@ -10,22 +10,14 @@
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
{{- $twitterSite := "" }}
{{- with site.Params.social.twitter }}
{{- $twitterSite = . }}
{{- else }}
{{- with site.Social.twitter }}
{{- $twitterSite = . }}
{{- $hugoVersion := "0.120.0" }}
{{- if ge hugo.Version $hugoVersion }}
{{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }}
{{- with site.Params.social }}
{{- if reflect.IsMap . }}
{{- with .twitter }}
{{- $content := . }}
{{- if not (strings.HasPrefix . "@") }}
{{- $content = printf "@%v" . }}
{{- end }}
<meta name="twitter:site" content="{{ $content }}"/>
{{- end }}
{{- end }}
{{- end }}
{{- with $twitterSite }}
{{- $content := . }}
{{- if not (strings.HasPrefix . "@") }}
{{- $content = printf "@%v" . }}
{{- end }}
<meta name="twitter:site" content="{{ $content }}">
{{- end }}