diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-03 12:51:52 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-03 12:52:23 +0200 |
| commit | 6c6b1bd1035ae68a18bd83faf7ff1297ead60e8c (patch) | |
| tree | 0a9b6c3388af549cd7d59b6e680837d31d9dc3b2 /layouts/_default | |
| parent | 1283f3d31243d1ac63ce718c4039ba6b85f5d721 (diff) | |
| download | gohugo-theme-ed-6c6b1bd1035ae68a18bd83faf7ff1297ead60e8c.tar.gz | |
Do not allow modification of date formats that are required by spec
Diffstat (limited to 'layouts/_default')
| -rw-r--r-- | layouts/_default/list.atom.xml | 6 | ||||
| -rw-r--r-- | layouts/_default/list.feed.xml | 6 | ||||
| -rw-r--r-- | layouts/_default/list.json.json | 4 | ||||
| -rw-r--r-- | layouts/_default/sitemap.xml | 4 |
4 files changed, 9 insertions, 11 deletions
diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index 75892fd..5da5f25 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -33,7 +33,7 @@ </author>{{ end }}{{ with site.Params.Copyright }}{{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "©" "©" }} <rights>{{ $copyright | plainify }}</rights>{{ end }} <generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>{{ if not site.LastChange.IsZero }} - <updated>{{ site.LastChange.UTC.Format site.Params.dateFormatFeed }}</updated>{{ end }}{{ $uuid := sha1 (site.BaseURL | absURL) }} + <updated>{{ site.LastChange.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 := . }} @@ -42,8 +42,8 @@ <link rel="alternate" type="type/html" href="{{ $url }}?utm_source=atom_feed" /> {{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}{{ range first 5 (site.RegularPages.Related .) }} <link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />{{ end }} - <published>{{ (.PublishDate.Format site.Params.dateFormatFeed) | html }}</published>{{ if ne .Date .Lastmod }} - <updated>{{ .Lastmod.UTC.Format site.Params.dateFormatFeed }}</updated>{{ end }} + <published>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</published>{{ if ne .Date .Lastmod }} + <updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>{{ end }} <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> {{ if .Params.author }} {{- $author_type := (printf "%T" .Params.author) }} diff --git a/layouts/_default/list.feed.xml b/layouts/_default/list.feed.xml index ae16aca..d66688b 100644 --- a/layouts/_default/list.feed.xml +++ b/layouts/_default/list.feed.xml @@ -14,7 +14,7 @@ {{- $limit := site.Params.feedSize | default 25 -}} {{- $pages = $pages | first $limit -}} -{{- safeHTML "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" }} +{{- 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/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" @@ -49,11 +49,11 @@ {{ 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 "©" "©" }} <copyright>{{ $copyright | plainify }}</copyright>{{ end }}{{ if not site.LastChange.IsZero }} - <lastBuildDate>{{ site.LastChange.UTC.Format site.Params.dateFormatRFC822Z | html }}</lastBuildDate>{{ end }}{{- range $pages }} + <lastBuildDate>{{ site.LastChange.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> - <pubDate>{{ .PublishDate.UTC.Format site.Params.dateFormatRFC822Z | html }}</pubDate> + <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <category>{{ .Section }}</category>{{ range (.GetTerms "tags") }} <category>{{ .LinkTitle }}</category>{{end}} <guid isPermaLink="false">{{ md5 .Permalink }}</guid> diff --git a/layouts/_default/list.json.json b/layouts/_default/list.json.json index b912df0..70ea7a4 100644 --- a/layouts/_default/list.json.json +++ b/layouts/_default/list.json.json @@ -36,8 +36,8 @@ "url": {{ printf "%s?utm_source=json_feed" .Permalink | jsonify }}, "title": {{ .Title | plainify | chomp | jsonify }}, "summary": {{ .Summary | plainify | chomp | jsonify }}, - "date_published": {{ .PublishDate.UTC.Format site.Params.dateFormatFeed | jsonify }}{{ if ne .Date .Lastmod }}, - "date_modified" : {{ .Lastmod.UTC.Format site.Params.dateFormatFeed | jsonify }}{{ end }} + "date_published": {{ .PublishDate.Format "2006-01-02T15:04:05Z07:00" | jsonify }}{{ if ne .Date .Lastmod }}, + "date_modified" : {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | jsonify }}{{ end }} } {{- end}} ] diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml index 3745dc5..939dcac 100644 --- a/layouts/_default/sitemap.xml +++ b/layouts/_default/sitemap.xml @@ -1,12 +1,10 @@ -{{- $dateFormat := site.Params.dateFormatFeed | default "2006-01-02T15:04:05-07:00" -}} - {{- 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 .Data.Pages }}{{ if ne .Params.private true }} <url> <loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }} - <lastmod>{{ safeHTML ( .Lastmod.Format $dateFormat | html ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} + <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05Z07:00" | jsonify ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} <priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }} <xhtml:link |
