small fixes

This commit is contained in:
teldra 2022-06-15 22:13:03 +02:00
parent acb468f46e
commit 7ce041fa4b
1 changed files with 93 additions and 81 deletions

View File

@ -2,94 +2,106 @@
{{- $title := .Site.Title -}} {{- $title := .Site.Title -}}
{{- $desc := "" -}} {{- $desc := "" -}}
{{- $i18n_section := i18n "news" -}} {{- $i18n_section := i18n "news" -}}
{{- if .IsHome -}} {{- if .IsHome -}}
{{- $desc = printf "Aktuelle Informationen vom %s" $title -}} {{- $desc = printf "Aktuelle Informationen vom %s" $title -}}
{{- $title = printf "%s: %s" $title $i18n_section -}} {{- $title = printf "%s: %s" $title $i18n_section -}}
{{ else if in .Site.Params.mainMenu .Section }} {{ else if in .Site.Params.mainMenu .Section }}
{{- $desc = printf "Aktuelle Informationen vom %s" .Site.Title -}} {{- $desc = printf "Aktuelle Informationen vom %s" .Site.Title -}}
{{ $i18n_section = i18n .Section }} {{ $i18n_section = i18n .Section }}
{{- $title = printf "%s: %s" .Site.Title $i18n_section -}} {{- $title = printf "%s: %s" .Site.Title $i18n_section -}}
{{- end -}} {{- end -}}
{{- $pages := where (where site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" .Site.Params.searchSections -}} {{- $pages := where (where site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" .Site.Params.searchSections -}}
{{- if eq .Section "events" -}} {{- if eq .Section "events" -}}
{{- $pages = where $pages ".Params.when" "ne" nil -}} {{- $pages = where $pages ".Params.when" "ne" nil -}}
{{- end -}} {{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ $title }}</title> <title>{{ $title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<description>{{- $desc -}}</description> <description>{{- $desc -}}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }} <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }} <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }} <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" -}} {{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}} {{- end -}}
{{ range $pages }} {{ range $pages }}
{{ if or (eq .Lastmod .Date) (gt .Lastmod (.Date.AddDate 0 0 -1)) }} {{ if or (eq .Lastmod .Date) (gt .Lastmod (.Date.AddDate 0 0 -1)) }}
{{ $when := .Params.when }} {{ $when := .Params.when }}
{{ $about := .Params.about }} {{ $about := .Params.about }}
{{ $covid := .Params.covid }} {{ $covid := .Params.covid }}
{{ $contact := .Params.contact }} {{ $contact := .Params.contact }}
{{ $price := .Params.price }} {{ $price := .Params.price }}
{{ $featured := .Params.featured }} {{ $featured := .Params.featured }}
{{ $categories := slice }} {{ $categories := slice }}
{{ range .Params.categories }} {{ range .Params.categories }}
{{ $categories = $categories | append . }} {{ $categories = $categories | append . }}
{{ end }} {{ end }}
{{ $events := slice }} {{ $events := slice }}
{{ range .Params.events }} {{ range .Params.events }}
{{ $events = $events | append . }} {{ $events = $events | append . }}
{{ end }} {{ end }}
{{ $tags := slice }} {{ $tags := slice }}
{{ range .Params.tags }} {{ range .Params.tags }}
{{ $tags = $tags | append . }} {{ $tags = $tags | append . }}
{{ end }} {{ end }}
{{ $images := slice }} {{ $images := slice }}
{{ $hash := slice $when $about $categories $events $covid $contact $price $featured $tags .Date .Lastmod .Title .Content }} {{ $hash := slice $when $about $categories $events $covid $contact $price $featured $tags .Date .Lastmod .Title .Content }}
{{ $hash = delimit $hash ", " }} {{ $hash = delimit $hash ", " }}
{{ $hash = md5 $hash }} {{ $hash = md5 $hash }}
<item>
<title>{{ .Title }}</title> <item>
<link>{{ .Permalink }}</link> <title>{{ .Title }}</title>
<pubDate>{{ .Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <link>{{ .Permalink }}</link>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} <pubDate>{{ .Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<guid>{{ .Permalink }}-{{ $hash }}</guid> {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<description> <guid>{{ .Permalink }}-{{ $hash }}</guid>
{{- $c := .Content -}} <description>
{{- $summary := "" -}} {{- $c := .Content -}}
{{- if in .RawContent "<!--more-->" -}}
{{- $tmp := split .RawContent "<!--more-->" -}} {{- $summary := "" -}}
{{- $c = index $tmp 0 | markdownify -}} {{- if in .RawContent "<!--more-->" -}}
{{- else if $c -}} {{- $tmp := split .RawContent "<!--more-->" -}}
{{- if hasPrefix .Summary "<p>" -}} {{- $c = index $tmp 0 | markdownify -}}
{{- $c = .Summary -}} {{- else if $c -}}
{{- else -}} {{- if hasPrefix .Summary "<p>" -}}
{{- $c = printf "<p>%s</p>" .Summary -}} {{- $c = .Summary -}}
{{- end -}} {{- else -}}
{{- end -}} {{- $c = printf "<p>%s</p>" .Summary -}}
{{- $banner := .Resources.GetMatch "banner*" -}} {{- end -}}
{{- if $banner -}} {{- end -}}
{{- $c = printf "<p><img loading=\"lazy\" src=\"%s\" width=\"%d\" height=\"%d\" /></p>%s" $banner.Permalink $banner.Width $banner.Height $c -}}
{{- end -}} {{- $banner := .Resources.GetMatch "banner*" -}}
{{- if $when -}} {{- if $banner -}}
{{- $c = printf "<p><b>%s</b></p>%s" $when $c -}} {{- $c = printf "<p><img loading=\"lazy\" src=\"%s\" width=\"%d\" height=\"%d\" /></p>%s" $banner.Permalink $banner.Width $banner.Height $c -}}
{{- end -}} {{- end -}}
{{- range .Resources.ByType "image" -}}
{{- $img := . -}} {{- if $when -}}
{{- if not (hasPrefix $img.Name "banner") -}} {{- $c = printf "<p><b>%s</b></p>%s" $when $c -}}
{{- $c = printf "%s<p><img loading=\"lazy\" src=\"%s\" width=\"%d\" height=\"%d\" /></p>" $c $img.Permalink $img.Width $img.Height -}} {{- end -}}
{{- end -}}
{{- end -}} {{- range .Resources.ByType "image" -}}
{{- printf "<![CDATA[%s]]>" ($c | safeHTML) -}} {{- $img := . -}}
{{- end -}} {{- if not (hasPrefix $img.Name "banner") -}}
</description> {{- $c = printf "%s<p><img loading=\"lazy\" src=\"%s\" width=\"%d\" height=\"%d\" /></p>" $c $img.Permalink $img.Width $img.Height -}}
</item> {{- end -}}
{{ end }} {{- end -}}
</channel>
{{- printf "<![CDATA[%s]]>" $c | safeHTML -}}
{{- end -}}
</description>
</item>
{{ end }}
</channel>
</rss> </rss>
{{- end -}} {{- end -}}