Add Atom feeds
This commit is contained in:
@@ -20,6 +20,7 @@ It's a versatile canvas that serves most web needs.
|
||||
|
||||
- Accessibility
|
||||
- Analytics
|
||||
- Atom feed
|
||||
- Authors
|
||||
- Automatic switching between light and dark color schemes
|
||||
- Blog
|
||||
@@ -271,6 +272,10 @@ format = ":date_long" # Hugo date format
|
||||
[paige.feed]
|
||||
hide_page = false
|
||||
|
||||
[paige.feed.atom]
|
||||
link_to_page = false # Link to the page instead of the front matter link, if present
|
||||
page_link = "⏎" # If a front matter link is present, and link_to_page is false, link to the page with this text
|
||||
|
||||
[paige.feed.rss]
|
||||
managing_editor = ""
|
||||
web_master = ""
|
||||
|
@@ -85,7 +85,9 @@ startlevel = 2
|
||||
path = "github.com/willfaught/paige"
|
||||
|
||||
[outputs]
|
||||
home = ["html", "json", "rss"]
|
||||
home = ["atom", "html", "json", "rss"]
|
||||
section = ["atom", "html", "rss"]
|
||||
taxonomy = ["atom", "html", "rss"]
|
||||
|
||||
[params.authors.will-faught]
|
||||
default = true
|
||||
@@ -96,6 +98,11 @@ url = "https://willfaught.com/paige"
|
||||
[params.paige.git]
|
||||
commit_url = "https://github.com/willfaught/paige/commit/%s"
|
||||
|
||||
[[params.paige.feed.atom.authors]]
|
||||
email = "will.faught@example.com"
|
||||
name = "Will Faught"
|
||||
url = "https://willfaught.com/paige"
|
||||
|
||||
[params.paige.feed.rss]
|
||||
managing_editor = "Will Faught"
|
||||
web_master = "Will Faught"
|
||||
|
13
hugo.toml
13
hugo.toml
@@ -1,3 +1,6 @@
|
||||
[mediatypes."application/atom+xml"]
|
||||
suffixes = ["xml"]
|
||||
|
||||
[module.hugoversion]
|
||||
min = "0.111.3"
|
||||
extended = true
|
||||
@@ -84,6 +87,16 @@ source = "paige/node_modules/katex/dist"
|
||||
target = "assets/js/paige/katex"
|
||||
includeFiles = ["katex.min.js"]
|
||||
|
||||
[outputformats.atom]
|
||||
basename = "atom"
|
||||
ishtml = false
|
||||
isplaintext = false
|
||||
mediatype = "application/atom+xml"
|
||||
name = "atom"
|
||||
nougly = true
|
||||
permalinkable = false
|
||||
rel = "alternate"
|
||||
|
||||
[outputformats.rss]
|
||||
basename = "rss"
|
||||
ishtml = false
|
||||
|
156
layouts/_default/list.atom.xml
Normal file
156
layouts/_default/list.atom.xml
Normal file
@@ -0,0 +1,156 @@
|
||||
{{ $page := . }}
|
||||
|
||||
{{ $authors := $page.Param "paige.feed.atom.authors" }}
|
||||
{{ $lang := site.LanguageCode | default site.Language.Lang }}
|
||||
{{ $limit := site.Config.Services.RSS.Limit }}
|
||||
{{ $pagetitle := $page.Title | markdownify }}
|
||||
{{ $rights := site.Copyright }}
|
||||
{{ $sitetitle := site.Title | markdownify }}
|
||||
{{ $subpages := (cond $page.IsHome site $page).RegularPages }}
|
||||
{{ $subtitle := $page.Description }}
|
||||
{{ $title := "" }}
|
||||
{{ $updated := time site.LastChange }}
|
||||
|
||||
{{ if and $pagetitle $sitetitle }}
|
||||
{{ if $page.IsHome }}
|
||||
{{ $title = $pagetitle | safeHTML }}
|
||||
{{ else }}
|
||||
{{ $title = printf "%s · %s" $pagetitle $sitetitle | safeHTML }}
|
||||
{{ end }}
|
||||
{{ else if $pagetitle }}
|
||||
{{ $title = $pagetitle | safeHTML }}
|
||||
{{ else if $sitetitle }}
|
||||
{{ $title = $sitetitle | safeHTML }}
|
||||
{{ end }}
|
||||
|
||||
{{ $subpages = where $subpages "Params.paige.feed.hide_page" "ne" true }}
|
||||
|
||||
{{ if ge $limit 0 }}
|
||||
{{ $subpages = $subpages | first $limit }}
|
||||
{{ end }}
|
||||
|
||||
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }}
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" {{ with $lang }} xml:lang="{{ . }}" {{ end }}>
|
||||
{{ range $authors }}
|
||||
<author>
|
||||
{{ with .email }}
|
||||
<email>{{ . }}</email>
|
||||
{{ end }}
|
||||
{{ with .name }}
|
||||
<name>{{ . }}</name>
|
||||
{{ end }}
|
||||
{{ with .url }}
|
||||
<uri>{{ . }}</uri>
|
||||
{{ end }}
|
||||
</author>
|
||||
{{ end }}
|
||||
{{ $id := "" }}
|
||||
{{ if .Params.id }}
|
||||
{{ $id = .Params.id }}
|
||||
{{ else if not $page.Date.IsZero }}
|
||||
{{ $id = printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.Date.Format "2006-01-02") (.Date.Format "2006-01-02T15:04:05Z07:00") }}
|
||||
{{ else }}
|
||||
{{ $id = .Permalink }}
|
||||
{{ end }}
|
||||
<id>{{ $id }}</id>
|
||||
{{ printf `<link href="%s" rel="self" type="application/atom+xml"/>` ($page.Permalink | safeURL) | safeHTML }}
|
||||
{{ range $page.AlternativeOutputFormats }}
|
||||
{{ if eq .Rel "alternate" }}
|
||||
{{ printf `<link href="%s" rel="alternate" type="%s"/>` (.Permalink | safeURL) .MediaType | safeHTML }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ range $t := $page.Translations }}
|
||||
{{ range .OutputFormats }}
|
||||
{{ if eq .Rel "alternate" }}
|
||||
{{ printf `<link href="%s" hreflang="%s" rel="alternate" type="%s"/>` (.Permalink | safeURL) $t.Lang .MediaType | safeHTML }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with $rights }}
|
||||
<rights type="html">{{ printf "<![CDATA[%s]]>" (. | markdownify) | safeHTML }}</rights>
|
||||
{{ end }}
|
||||
{{ with $subtitle }}
|
||||
<subtitle type="html">{{ printf "<![CDATA[%s]]>" (. | markdownify) | safeHTML}}</subtitle>
|
||||
{{ end }}
|
||||
{{ if not $title }}
|
||||
{{ warnf "layouts/_default/list.atom.xml: Page %s does not have a title" $page.RelPermalink }}
|
||||
{{ end }}
|
||||
{{ printf `<title type="html"><![CDATA[%s]]></title>` ($title | markdownify) | safeHTML }}
|
||||
<updated>{{ $updated.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
||||
{{ $ids := dict }}
|
||||
{{ range $subpage := $subpages }}
|
||||
<entry>
|
||||
{{ with partial "paige/authors.html" . }}
|
||||
{{ range . }}
|
||||
<author>
|
||||
{{ with .email }}
|
||||
<email>{{ . }}</email>
|
||||
{{ end }}
|
||||
{{ with .name }}
|
||||
<name>{{ . }}</name>
|
||||
{{ end }}
|
||||
{{ with .url }}
|
||||
<uri>{{ . }}</uri>
|
||||
{{ end }}
|
||||
</author>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $content := .Content }}
|
||||
{{ if $content }}
|
||||
{{ if and .Params.link (not (.Param "paige.feed.atom.link_to_page")) }}
|
||||
{{ $link := or (.Param "paige.feed.atom.page_link" | markdownify) "⏎" }}
|
||||
{{ $footer := printf `<p><a href="%s" title="%s">%s</a></p>` .Permalink .Title $link }}
|
||||
{{ $content = print $content $footer }}
|
||||
{{ end }}
|
||||
<content type="html">{{ printf "<![CDATA[%s]]>" $content | safeHTML }}</content>
|
||||
{{ end }}
|
||||
{{ $id := "" }}
|
||||
{{ if .Params.id }}
|
||||
{{ $id = .Params.id }}
|
||||
{{ else if not .Date.IsZero }}
|
||||
{{ $id = printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.Date.Format "2006-01-02") (.Date.Format "2006-01-02T15:04:05Z07:00") }}
|
||||
{{ else }}
|
||||
{{ $id = .RelPermalink }}
|
||||
{{ end }}
|
||||
{{ with index $ids $id }}
|
||||
{{ warnf "layouts/_default/list.atom.xml: Pages %s and %s have the same ID" . $subpage.RelPermalink }}
|
||||
{{ end }}
|
||||
{{ $ids = merge (dict $id .RelPermalink) $ids }}
|
||||
<id>{{ $id }}</id>
|
||||
{{ range .OutputFormats }}
|
||||
{{ if eq .Rel "alternate" }}
|
||||
{{ printf `<link href="%s" rel="alternate" type="%s"/>` (.Permalink | safeURL) .MediaType | safeHTML }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ range $t := .Translations }}
|
||||
{{ range .OutputFormats }}
|
||||
{{ if eq .Rel "alternate" }}
|
||||
{{ printf `<link href="%s" hreflang="%s" rel="alternate" type="%s"/>` (.Permalink | safeURL) $t.Lang .MediaType | safeHTML }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if and .Params.link (not (.Param "paige.feed.atom.link_to_page")) }}
|
||||
<link href="{{ .Params.link | safeURL }}" rel="alternate" type="text/html"/>
|
||||
{{ else }}
|
||||
<link href="{{ .Permalink | safeURL }}" rel="alternate" type="text/html"/>
|
||||
{{ end }}
|
||||
{{ if not .PublishDate.IsZero }}
|
||||
<published>{{ .PublishDate.Format "2006-01-02T15:04:05Z07:00" }}</published>
|
||||
{{ end }}
|
||||
{{ with site.Copyright }}
|
||||
<rights type="html">{{ printf "<![CDATA[%s]]>" (. | markdownify) | safeHTML }}</rights>
|
||||
{{ end }}
|
||||
{{ with .Description }}
|
||||
<summary type="html">{{ printf "<![CDATA[%s]]>" (. | markdownify) | safeHTML }}</summary>
|
||||
{{ end }}
|
||||
{{ if not .Title }}
|
||||
{{ warnf "layouts/_default/list.atom.xml: %s: Page %s does not have a title" .RelPermalink }}
|
||||
{{ end }}
|
||||
{{ printf `<title type="html"><![CDATA[%s]]></title>` (.Title | markdownify) | safeHTML }}
|
||||
{{ if .Lastmod.IsZero }}
|
||||
{{ warnf "layouts/_default/list.atom.xml: Page %s does not have a modified date" .RelPermalink }}
|
||||
{{ end }}
|
||||
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
||||
</entry>
|
||||
{{ end }}
|
||||
</feed>
|
Reference in New Issue
Block a user