Skip to content

Commit d4016dd

Browse files
jmooringbep
authored andcommitted
tpl/tplimpl: Deprecate .Site.Author usage in RSS template
1 parent 4910312 commit d4016dd

1 file changed

Lines changed: 45 additions & 23 deletions

File tree

  • tpl/tplimpl/embedded/templates/_default
Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,61 @@
1-
{{- $pctx := . -}}
2-
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
3-
{{- $pages := slice -}}
4-
{{- if or $.IsHome $.IsSection -}}
5-
{{- $pages = $pctx.RegularPages -}}
6-
{{- else -}}
7-
{{- $pages = $pctx.Pages -}}
8-
{{- end -}}
9-
{{- $limit := .Site.Config.Services.RSS.Limit -}}
10-
{{- if ge $limit 1 -}}
11-
{{- $pages = $pages | first $limit -}}
12-
{{- end -}}
1+
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
2+
{{- $authorEmail := "" }}
3+
{{- with site.Params.author.email }}
4+
{{- $authorEmail = . }}
5+
{{- else }}
6+
{{- with site.Author.email }}
7+
{{- $authorEmail = . }}
8+
{{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }}
9+
{{- end }}
10+
{{- end }}
11+
12+
{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
13+
{{- $authorName := "" }}
14+
{{- with site.Params.author.name }}
15+
{{- $authorName = . }}
16+
{{- else }}
17+
{{- with site.Author.name }}
18+
{{- $authorName = . }}
19+
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
20+
{{- end }}
21+
{{- end }}
22+
23+
{{- $pctx := . }}
24+
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
25+
{{- $pages := slice }}
26+
{{- if or $.IsHome $.IsSection }}
27+
{{- $pages = $pctx.RegularPages }}
28+
{{- else }}
29+
{{- $pages = $pctx.Pages }}
30+
{{- end }}
31+
{{- $limit := .Site.Config.Services.RSS.Limit }}
32+
{{- if ge $limit 1 }}
33+
{{- $pages = $pages | first $limit }}
34+
{{- end }}
1335
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
1436
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
1537
<channel>
16-
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
38+
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
1739
<link>{{ .Permalink }}</link>
18-
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
40+
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
1941
<generator>Hugo -- gohugo.io</generator>
20-
<language>{{ site.Language.LanguageCode }}</language>{{ with .Site.Author.email }}
21-
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
22-
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
23-
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
42+
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
43+
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
44+
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
45+
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
2446
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
25-
{{- with .OutputFormats.Get "RSS" -}}
47+
{{- with .OutputFormats.Get "RSS" }}
2648
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
27-
{{- end -}}
28-
{{ range $pages }}
49+
{{- end }}
50+
{{- range $pages }}
2951
<item>
3052
<title>{{ .Title }}</title>
3153
<link>{{ .Permalink }}</link>
3254
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
33-
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
55+
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
3456
<guid>{{ .Permalink }}</guid>
3557
<description>{{ .Summary | html }}</description>
3658
</item>
37-
{{ end }}
59+
{{- end }}
3860
</channel>
3961
</rss>

0 commit comments

Comments
 (0)