mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-25 06:20:40 +00:00
refactor: cleanup Atom feed template and remove CDATA (#195)
This commit is contained in:
parent
6f0cd03608
commit
e5b269fb36
@ -1,51 +1,49 @@
|
|||||||
{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} {{/* ref: https://validator.w3.org/feed/docs/atom.html */}}
|
{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }}
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom"{{ with .Site.Language.Lang }} xml:lang="{{ . }}"{{ end }}>
|
<feed xmlns="http://www.w3.org/2005/Atom"{{ with .Site.Language.Lang }} xml:lang="{{ . }}"{{ end }}>
|
||||||
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
|
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
|
||||||
{{- $title := .Site.Title -}}
|
{{- $title := .Site.Title -}}
|
||||||
{{- if not (eq .Kind "home") -}}
|
{{- if not (eq .Kind "home") }}
|
||||||
{{- $title = printf `%s on %s` (partial "utils/title" .) $title -}}
|
{{- $title = printf `%s on %s` (partial "utils/title" .) $title -}}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
|
<title>{{ trim ($title | plainify) "\n" }}</title>
|
||||||
{{ with .Site.Params.subtitle }}
|
{{- with .Site.Params.subtitle }}
|
||||||
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
|
<subtitle>{{ trim (. | plainify) "\n" }}</subtitle>
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ $output_formats := .OutputFormats }}
|
{{- $output_formats := .OutputFormats -}}
|
||||||
{{ range $output_formats -}}
|
{{- range $output_formats -}}
|
||||||
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
|
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
|
||||||
{{ with $output_formats.Get .Name }}
|
{{- with $output_formats.Get .Name }}
|
||||||
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
|
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
||||||
<generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>
|
{{- with .Site.Params.GeekblogAuthor -}}
|
||||||
{{ with .Site.Params.GeekblogAuthor -}}
|
{{- with index $.Site.Data.authors . }}
|
||||||
{{ with index $.Site.Data.authors . }}
|
|
||||||
<author>
|
<author>
|
||||||
<name>{{ .name }}</name>
|
<name>{{ .name }}</name>
|
||||||
{{ with .email }}
|
{{- with .email }}
|
||||||
<email>{{ . }}</email>
|
<email>{{ . }}</email>
|
||||||
{{ end -}}
|
{{- end }}
|
||||||
</author>
|
</author>
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<id>{{ .Permalink }}</id>
|
<id>{{ .Permalink }}</id>
|
||||||
{{- $pages := where .RegularPages "Type" "in" .Site.Params.mainSections -}}
|
{{- $pages := where .RegularPages "Type" "in" .Site.Params.mainSections -}}
|
||||||
{{- if (eq .Kind "home") -}}
|
{{- if (eq .Kind "home") -}}
|
||||||
{{- $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
|
{{- $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- range $pages }}
|
{{- range $page := $pages }}
|
||||||
{{ $page := . }}
|
|
||||||
<entry>
|
<entry>
|
||||||
{{ printf `<title type="html"><![CDATA[%s]]></title>` (partial "utils/title" .) | safeHTML }}
|
<title>{{ trim (partial "utils/title" . | plainify) "\n" }}</title>
|
||||||
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} />
|
<link href="{{ .Permalink }}" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} />
|
||||||
<id>{{ .Permalink }}</id>
|
<id>{{ .Permalink }}</id>
|
||||||
{{ with .Params.authors -}}
|
{{- with .Params.authors }}
|
||||||
{{- range sort . -}}
|
{{- range sort . }}
|
||||||
{{ $author := index $.Site.Data.authors . }}
|
{{- $author := index $.Site.Data.authors . }}
|
||||||
<author>
|
<author>
|
||||||
<name>{{ $author.name }}</name>
|
<name>{{ $author.name }}</name>
|
||||||
</author>
|
</author>
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
|
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
|
||||||
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
|
||||||
@ -54,20 +52,22 @@
|
|||||||
{{- $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) -}}
|
{{- $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) -}}
|
||||||
{{- $img = printf `<img src="%s" width="%d" height="%d" alt="%s" /><br/>` $featured.Permalink $featured.Width $featured.Height (default (partial "utils/title" $page) .Params.description) -}}
|
{{- $img = printf `<img src="%s" width="%d" height="%d" alt="%s" /><br/>` $featured.Permalink $featured.Width $featured.Height (default (partial "utils/title" $page) .Params.description) -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ printf `<content type="html"><![CDATA[%s%s]]></content>` $img .Content | safeHTML }}
|
<content type="html">
|
||||||
{{ with .Site.Taxonomies }}
|
{{ printf "%s%s" $img .Content | htmlEscape | safeHTML }}
|
||||||
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
|
</content>
|
||||||
{{ with $page.Param $taxo }}
|
{{- with .Site.Taxonomies }}
|
||||||
{{ $taxo_list := . }} <!-- $taxo_list will be the tags/categories list -->
|
{{- range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
|
||||||
{{ with $.Site.GetPage (printf "/%s" $taxo) }}
|
{{- with $page.Param $taxo }}
|
||||||
{{ $taxonomy_page := . }}
|
{{- $taxo_list := . -}} <!-- $taxo_list will be the tags/categories list -->
|
||||||
{{ range $taxo_list }} <!-- Below, assuming pretty URLs -->
|
{{- with $.Site.GetPage (printf "/%s" $taxo) }}
|
||||||
|
{{- $taxonomy_page := . -}}
|
||||||
|
{{- range $taxo_list }} <!-- Below, assuming pretty URLs -->
|
||||||
<category scheme="{{ printf "%s%s" $taxonomy_page.Permalink (. | urlize) }}" term="{{ (. | urlize) }}" label="{{ . }}" />
|
<category scheme="{{ printf "%s%s" $taxonomy_page.Permalink (. | urlize) }}" term="{{ (. | urlize) }}" label="{{ . }}" />
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
{{ end }}
|
{{- end }}
|
||||||
</entry>
|
</entry>
|
||||||
{{ end }}
|
{{- end }}
|
||||||
</feed>
|
</feed>
|
||||||
|
@ -65,15 +65,14 @@
|
|||||||
href="{{ index (index .Site.Data.assets "custom.css") "src" | relURL }}"
|
href="{{ index (index .Site.Data.assets "custom.css") "src" | relURL }}"
|
||||||
media="all"
|
media="all"
|
||||||
/>
|
/>
|
||||||
|
{{- with .OutputFormats.Get "html" }}
|
||||||
<link rel="canonical" href="{{ .Permalink }}" />
|
{{ printf `<link href=%q rel=%q type=%q />` .Permalink .Rel .MediaType.Type | safeHTML }}
|
||||||
|
{{- end }}
|
||||||
{{- with (.Site.GetPage "home").OutputFormats.Get "atom" }}
|
{{- $output_formats := (.Site.GetPage "home").OutputFormats }}
|
||||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s Atom Feed">` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
{{- range $format := (.Site.GetPage "home").OutputFormats }}
|
||||||
|
{{- if not (eq $format.Rel "canonical") }}
|
||||||
|
{{ printf `<link href=%q rel=%q type=%q title="%s %s Feed" />` $format.Permalink $format.Rel $format.MediaType.Type $.Site.Title $format.Name | safeHTML }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- with (.Site.GetPage "home").OutputFormats.Get "json" }}
|
|
||||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s JSON Feed">` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if (default false $.Site.Params.GeekblogOverwriteHTMLBase) }}
|
{{- if (default false $.Site.Params.GeekblogOverwriteHTMLBase) }}
|
||||||
|
Loading…
Reference in New Issue
Block a user