Skip to content

Commit

Permalink
Deprecation of .Site.Author fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
isotopp committed Sep 3, 2024
1 parent 06e6fe1 commit 639123e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 47 deletions.
15 changes: 7 additions & 8 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
baseURL: "https://blog.koehntopp.info"
languageCode: "en-us"
theme: "hugo-bootstrap-bare"
author:
isotopp:
name: "Kristian Köhntopp"
avatar: "isotopp.jpg"
fedi: "@[email protected]"
fediurl: "https://chaos.social/@isotopp"
email: "[email protected]"

title: "Die wunderbare Welt von Isotopp"

params:
Expand All @@ -18,6 +10,13 @@ params:
URL: "https://github.com/isotopp/isotopp.github.io/edit/main/content"
appendFilePath: True
Text: "Suggest Changes"
author:
isotopp:
name: "Kristian Köhntopp"
avatar: "isotopp.jpg"
fedi: "@[email protected]"
fediurl: "https://chaos.social/@isotopp"
email: "[email protected]"

frontmatter:
date: [":filename", ":default"]
Expand Down
47 changes: 30 additions & 17 deletions layouts/_default/rss.xml
Original file line number Diff line number Diff line change
@@ -1,40 +1,53 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</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 .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 }}
<language>{{.}}</language>{{end}}

{{- $siteAuthor := index .Site.Params.author "isotopp" -}}

{{ with $siteAuthor.email }}
<managingEditor>{{.}}{{ with $siteAuthor.name }} ({{.}}){{end}}</managingEditor>{{end}}

{{ with $siteAuthor.email }}
<webMaster>{{.}}{{ with $siteAuthor.name }} ({{.}}){{end}}</webMaster>{{end}}

{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ now.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 />" .Permalink .MediaType | safeHTML }}
{{- end -}}

{{ range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ (.Param "date").Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}

{{- $authorKey := .Param "author" | default "isotopp" -}}
{{- $author := index $.Site.Params.author $authorKey -}}

{{ with $author.email }}<author>{{.}}{{ with $author.name }} ({{.}}){{end}}</author>{{end}}

<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
</item>
{{ end }}
</channel>
</rss>

4 changes: 3 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{{ define "title" }}{{ .Title | markdownify }} | {{ .Site.Title }}{{ end }}
{{ define "main" }}
{{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }}
{{ $author := (index .Site.Author (string (.Param "author"))) }}
{{ $authorKey := .Param "author" | default "isotopp" }}
{{ $author := index .Site.Params.author $authorKey }}
{{ $fedi := $author.fedi }}
{{ $fediurl := $author.fediurl }}
{{ $name := $author.name }}
{{ $avatar := $author.avatar }}
{{ $email := $author.email }}

<div class="page">
<article class="{{ .Title | urlize }}-page">
<div class='row justify-content-center text-center my-4 mx-0'>
Expand Down
3 changes: 2 additions & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ <h1 class="title mb-lg-4 text-white">
{{/* {{ .Content }} */}}

{{- range (.Paginate ( where site.RegularPages "Section" "posts" ) ).Pages }}
{{- $author := (index .Site.Author (string (.Param "author"))) }}
{{- $authorKey := .Param "author" | default "isotopp" }}
{{- $author := index .Site.Params.author $authorKey }}
{{- $fedi := $author.fedi }}
{{- $fediurl := $author.fediurl }}
{{- $avatar := $author.avatar }}
Expand Down
8 changes: 5 additions & 3 deletions layouts/partials/head-meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
<meta property="og:type" content="website" />
{{- end }}
<!-- Twitter card -->
{{- $author_fedi := (index .Site.Author (string (.Param "author"))).fedi }}
{{- $author_url := (index .Site.Author (string (.Param "author"))).fediurl }}
{{- $author_email := (index .Site.Author (string (.Param "author"))).email }}
{{- $author_key := .Param "author" | default "isotopp" -}}
{{- $author := index .Site.Params.author $author_key -}}
{{- $author_fedi := $author.fedi -}}
{{- $author_url := $author.fediurl -}}
{{- $author_email := $author.email -}}
<meta name="fediverse:creator" content="{{ $author_fedi }}">
<meta property="og:image" content='{{ .Param "feature-img" | absURL }}' />
<meta name="twitter:card" content="summary_large_image" />
Expand Down
43 changes: 26 additions & 17 deletions layouts/taxonomy/mysql.rss.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</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 .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 }}
<language>{{.}}</language>{{end}}

{{- $siteAuthor := index .Site.Params.author "isotopp" -}}

{{ with $siteAuthor.email }}
<managingEditor>{{.}}{{ with $siteAuthor.name }} ({{.}}){{end}}</managingEditor>{{end}}

{{ with $siteAuthor.email }}
<webMaster>{{.}}{{ with $siteAuthor.name }} ({{.}}){{end}}</webMaster>{{end}}

{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ now.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" -}}
Expand All @@ -30,11 +38,12 @@
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ (.Param "date").Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
{{- $authorKey := .Param "author" | default "isotopp" -}}
{{- $author := index $.Site.Params.author $authorKey -}}
{{ with $author.email }}<author>{{.}}{{ with $author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
</item>
{{ end }}
</channel>
</rss>

0 comments on commit 639123e

Please sign in to comment.