Move the web feeds as its own theme component

This will make my theme creation process smoother now that I don't have
to migrate per theme. I can focus more polishing the aesthetics of the
theme.

Though, this does add an extra step for the users but that can be
mitigated by writing good documentation (right?).
This commit is contained in:
Gabriel Arazas 2020-10-21 11:23:00 +08:00
parent 25074c2b8c
commit d9ece82910
3 changed files with 0 additions and 154 deletions

View File

@ -1,56 +0,0 @@
{{- /* This template was based from the Atom syndication format at IETF RFC #4287 (https://tools.ietf.org/html/rfc4287). */ -}}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
{{- range .AlternativeOutputFormats }}
{{- printf "<link rel=%q type=%q href=%q/>" .Rel .MediaType .Permalink | safeHTML }}
{{- end }}
<rights>{{ with .Site.Copyright }}{{ . }}{{ else }}© {{ now.Year }} {{ with .Site.Author.name }}{{ . }}{{ end }}{{ end }}</rights>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}" type="text">Hugo</generator>
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>
<id>{{ "" | absLangURL }}</id>
{{- /* ICON, AHOY! */ -}}
<icon>{{ "icon.png" | absURL }}</icon>
{{ with .Site.Author }}
<author>
<name>{{ .name }}</name>
{{ with .email }}<email>{{ . }}</email>{{ end }}
</author>
{{ end }}
{{- /* Generate each valid regular pages (with as an individual entry in the feed. */ -}}
{{ $limit := cond (gt .Site.Params.feedLimit 0) .Site.Params.feedLimit 10 }}
{{ $pages := .Pages }}
{{ if .IsHome }}
{{ $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }}
{{ end }}
{{ range first $limit (where $pages "Params.hidden" "!=" true) }}
<entry>
<id>{{ .Permalink }}</id>
<title type="text">{{ .Title }}</title>
<link rel="alternate" href="{{ .Permalink }}" hreflang="{{ .Site.Language.Lang }}" title="{{ .Title | safeHTML }}"/>
{{- range .Params.author }}
<author>
<name>{{ .name }}<name>{{ with .email }}
<email>{{ . }}</email>{{ end }}
</author>
{{- end }}
{{- range .Params.tags }}
<category term="{{ . }}"/>
{{- end }}
<published>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>
{{ with .Params.copyright }}
<rights type="html">{{ . | safeHTML }}<rights>
{{ end }}
<content type="html">{{ .Content | html }}</content>
</entry>
{{ end }}
</feed>

View File

@ -1,31 +0,0 @@
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}",
"home_page_url": "{{ "" | absLangURL }}",
"feed_url": "{{ with .OutputFormats.Get "json" }}{{ .Permalink }}{{ end }}",
"description": "Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}",
{{- /* ICON, AHOY! */ -}}
"favicon": "{{ "icon.png" | absURL }}",
"icon": "{{ "icon.png" | absURL }}",
{{- with .Site.Author }}
"author": {
"name": "{{ .name }}"
{{- with .email }},
"url": "mailto:{{ . }}"
{{ end }}
},
{{- end }}
"items":
{{- $limit := cond (gt .Site.Params.feedLimit 0) .Site.Params.feedLimit 10 -}}
{{ $pages := .Pages }}
{{ if .IsHome }}
{{ $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }}
{{ end }}
{{- $.Scratch.Add "index" slice -}}
{{ range first $limit (where $pages "Params.hidden" "!=" true) }}
{{- $.Scratch.Add "index" (dict "id" .Permalink "url" .Permalink "title" .Title "summary" (.Summary | safeHTML) "content_html" (.Content | safeHTML) "tags" .Params.tags "date_published" (.Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML) "date_modified" ( .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML ) ) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}
}

View File

@ -1,67 +0,0 @@
{{- /*
The reference used to create this template is at https://cyber.harvard.edu/rss/rss.html.
The template does miss out on certain things which I put it on a list for those who are interested:
* Since there's no standard for multiple authors (with <author>) in the <item> element, I decided it would be best to leave it out for now.
* The name was left out for certain elements that requires an email address (like <managingEditor>, <webMaster>, or <author> in the <item>.
* <item:guid> is a permalink to the HTML post.
* No <item:enclosure>.
* <item:description> contains the whole post; if you want to change it to <item:content:encoded> and make <item:description> a summarized version, refer to https://www.rssboard.org/rss-profile and change the description tag with `.Summary | safeHTML`.
*/ -}}
{{ 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>
{{- /* ICON, AHOY! */ -}}
<image>{{ "icon.png" | absURL }}</image>
{{ with .Site.LanguageCode }}
<language>{{.}}</language>
{{end}}
{{ with .Site.Author.email }}
<managingEditor>{{.}}</managingEditor>
<webMaster>{{.}}</webMaster>
{{end}}
<copyright>{{ with .Site.Copyright }}{{ . }}{{ else }}© {{ now.Year }} to the author(s) behind {{ .Site.Title }}{{ end }}</copyright>
{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
{{ end }}
<docs>https://cyber.harvard.edu/rss/rss.html</docs>
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{- /* Point the alternative output formats. */ -}}
{{ range .AlternativeOutputFormats }}
{{ printf "<atom:link href=%q rel=%q type=%q />" .Permalink .Rel .MediaType | safeHTML }}
{{ end }}
{{- /* Iterate each valid regular page. */ -}}
{{ $limit := cond (gt .Site.Params.feedLimit 0) .Site.Params.feedLimit 10 }}
{{ $pages := .Pages }}
{{ if .IsHome }}
{{ $pages = where $.Site.RegularPages "Type" "in" $.Site.Params.mainSections }}
{{ end }}
{{ range first $limit (where $pages "Params.hidden" "!=" true) }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
{{ range .Params.tags }}
<category>{{ . }}</category>
{{ end }}
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
</item>
{{ end }}
</channel>
</rss>