summaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/list.atom.xml6
-rw-r--r--layouts/_default/list.feed.xml6
-rw-r--r--layouts/partials/site-last-mod.html21
3 files changed, 29 insertions, 4 deletions
diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml
index eabd899..67ff79b 100644
--- a/layouts/_default/list.atom.xml
+++ b/layouts/_default/list.atom.xml
@@ -14,6 +14,8 @@
{{- $limit := site.Params.feedSize | default 25 -}}
{{- $pages = $pages | first $limit -}}
+{{- $siteLastMod := partial "site-last-mod.html" . -}}
+
{{- safeHTML "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" }}
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="{{ site.LanguageCode }}" xml:base="{{ site.BaseURL }}">
{{ printf `<title type="html"><![CDATA[%s]]></title>` (partial "title.html" .) | safeHTML }}
@@ -32,8 +34,8 @@
{{ with site.Author.email }}<email>{{ . | html }}</email>{{ end }}
</author>{{ end }}{{ with site.Params.Copyright }}{{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "&copy;" "©" }}
<rights>{{ $copyright | plainify }}</rights>{{ end }}
- <generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>{{ if not site.LastChange.IsZero }}
- <updated>{{ site.LastChange.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>{{ end }}{{ $uuid := sha1 (site.BaseURL | absURL) }}
+ <generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>{{ if ne $siteLastMod "" }}
+ <updated>{{ $siteLastMod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>{{ end }}{{ $uuid := sha1 (site.BaseURL | absURL) }}
<id>urn:uuid:{{ substr $uuid 0 8 }}-{{ substr $uuid 8 4 }}-5{{ substr $uuid 13 3 }}-{{ substr $uuid 16 1 }}9{{ substr $uuid 17 2 }}-{{ substr $uuid 21 12 }}</id>{{- range $pages }}
<entry>
{{- $url := .Permalink | absURL }}{{ $uuid := sha1 (.Permalink | absURL) }}{{ $page := . }}
diff --git a/layouts/_default/list.feed.xml b/layouts/_default/list.feed.xml
index d66688b..2bc3cb7 100644
--- a/layouts/_default/list.feed.xml
+++ b/layouts/_default/list.feed.xml
@@ -14,6 +14,8 @@
{{- $limit := site.Params.feedSize | default 25 -}}
{{- $pages = $pages | first $limit -}}
+{{- $siteLastMod := partial "site-last-mod.html" . -}}
+
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
@@ -48,8 +50,8 @@
<generator>Hugo {{ hugo.Version }}</generator>{{ with site.Author.name }}
{{ printf `<dc:creator type="html"><![CDATA[%s]]></dc:creator>` . | safeHTML }}{{ end }}{{ with site.LanguageCode }}
<language>{{ . }}</language>{{ end }}{{ with site.Params.Copyright }}{{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "&copy;" "©" }}
- <copyright>{{ $copyright | plainify }}</copyright>{{ end }}{{ if not site.LastChange.IsZero }}
- <lastBuildDate>{{ site.LastChange.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}{{- range $pages }}
+ <copyright>{{ $copyright | plainify }}</copyright>{{ end }}{{ if ne $siteLastMod "" }}
+ <lastBuildDate>{{ $siteLastMod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}{{- range $pages }}
<item>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<link>{{ .Permalink | absURL }}?utm_source=rss_feed</link>
diff --git a/layouts/partials/site-last-mod.html b/layouts/partials/site-last-mod.html
new file mode 100644
index 0000000..ecd3900
--- /dev/null
+++ b/layouts/partials/site-last-mod.html
@@ -0,0 +1,21 @@
+{{- /* The .Site.LastChange was deprecated in Hugo v0.123.0 */ -}}
+{{- /* Use .Site.Lastmod if .Site.Hugo.Version greater than or equal to v0.123.0 */ -}}
+{{- /* Otherwise, use .Site.LastChange */ -}}
+
+{{- /* For more see: https://github.com/gohugoio/hugo/releases/tag/v0.123.0 */ -}}
+
+{{- /* Usage: {{ $siteLastMod := partial "site-last-mod.html" . }} */ -}}
+
+{{- $siteLastMod := "" -}}
+
+{{- if ge site.Hugo.Version "0.123.0" -}}
+ {{- if not site.Lastmod.IsZero -}}
+ {{- $siteLastMod = site.Lastmod -}}
+ {{- end -}}
+{{- else -}}
+ {{- if not site.LastChange.IsZero -}}
+ {{- $siteLastMod = site.LastChange -}}
+ {{- end -}}
+{{- end -}}
+
+{{- return $siteLastMod -}}