Browse Source

new atom feed?

master
jk 4 years ago
parent
commit
56d40409d8
  1. 3
      .gitmodules
  2. 18
      config.toml
  3. 11
      data/authors.toml
  4. 1
      gohugo-theme-ananke
  5. 137
      themes/hugo-atom-feed/layouts/_default/list.atom.xml
  6. 108
      themes/nipponalba/layouts/index.atom
  7. 2
      themes/nipponalba/layouts/partials/head.html

3
.gitmodules

@ -0,0 +1,3 @@
[submodule "gohugo-theme-ananke"]
path = gohugo-theme-ananke
url = https://github.com/budparr/gohugo-theme-ananke.git

18
config.toml

@ -1,19 +1,30 @@
baseURL = "https://jk.nipponalba.scot"
languageCode = "en-gb"
title = "JK's homepage"
theme=["nipponalba", "hugo-atom-feed"]
theme=["nipponalba"]
summarylength=30
enableEmoji=true
defaultContentLanguage="en"
ignoreErrors = ["error-remote-getjson"]
[outputs]
home = ["html", "rss"] # default = ["HTML", "RSS"]
home = ["html", "rss", "atom"] # default = ["HTML", "RSS"]
section = ["html", "rss"] # default = ["HTML", "RSS"]
term = ["html", "rss"] # default = ["HTML", "RSS"]
taxonomy = ["html", "rss"] # default = ["HTML", "RSS"]
# Define a new ATOM output format
[outputFormats]
[outputFormats.ATOM]
name = "ATOM"
baseName = "feed"
mediaType = "application/atom+xml"
# Define a new ATOM media type
[mediaTypes]
[mediaTypes."application/atom+xml"]
suffixes = ["atom"]
[markup]
[markup.goldmark]
[markup.goldmark.extensions]
@ -55,6 +66,7 @@ images = ["images/profile.jpg"]
siteLogo = "images/na-sm.png"
keywords = ""
favicon = "favicons/"
mainSections = ["article"]
[languages.en.Params]
description = "Quintessentially Celtic, vehemently Viking, passionately European, unashamedly, proudly Scottish, craft beer and single malt whisky lover, enthusiastic cook, vegan, perpetually exhausted dad, pronouns: he/him"

11
data/authors.toml

@ -0,0 +1,11 @@
[default]
name = "J K 🇯🇵🏴"
uri = "https://jk.nipponalba.scot/"
email = "jk@nipponalba.scot"
image = "images/profile.jpg"
[jk]
name = "J K 🇯🇵🏴"
uri = "https://jk.nipponalba.scot/"
email = "jk@nipponalba.scot"
image = "images/profile.jpg"

1
gohugo-theme-ananke

@ -0,0 +1 @@
Subproject commit 8845854aa9ab5af79066e840d8c884fbbb8a269d

137
themes/hugo-atom-feed/layouts/_default/list.atom.xml

@ -1,108 +1,55 @@
{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} {{/* ref: https://validator.w3.org/feed/docs/atom.html */}}
<feed xmlns="http://www.w3.org/2005/Atom"{{ with site.LanguageCode }} xml:lang="{{ . }}"{{ end }}>
{{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ .Site.LanguageCode }}">
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
<link href="http://pubsubhubbub.superfeedr.com/" rel="hub"/>
{{- $title := site.Title -}}
{{- with .Title -}}
{{- if (not (eq . site.Title)) -}}
{{- $title = printf `%s %s %s` . (i18n "feed_title_on" | default "on") site.Title -}}
{{- end -}}
{{- end -}}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
{{ with (or (.Param "subtitle") (.Param "tagline")) }}
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
{{ end }}
{{ $output_formats := .OutputFormats }}
{{ range $output_formats -}}
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
{{ with $output_formats.Get .Name }}
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
{{- end -}}
{{- end }}
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ with site.Copyright }}
{{- $copyright := replace . "{year}" now.Year -}} {{/* In case the site.copyright uses a special string "{year}" */}}
{{- $copyright = replace $copyright "&copy;" "©" -}}
<rights>{{ $copyright | plainify }}</rights>
{{- end }}
{{ with .Param "feed" }}
{{/* For this to work, the $icon file should be present in the assets/ directory */}}
{{- $icon := .icon | default "icon.svg" -}}
{{- with resources.Get $icon -}}
<icon>{{ (. | fingerprint).Permalink }}</icon>
<title>{{ .Site.Title }}</title>
{{- with .Site.Params.brand.tagline }}
<subtitle>{{ . }}</subtitle>
{{- end }}
{{/* For this to work, the $logo file should be present in the assets/ directory */}}
{{- $logo := .logo | default "logo.svg" -}}
{{- with resources.Get $logo -}}
<logo>{{ (. | fingerprint).Permalink }}</logo>
{{- end }}
{{ end }}
{{ with site.Author.name -}}
<id>{{ "/" | absLangURL }}</id>
<author>
<name>{{ . }}</name>
{{ with site.Author.email }}
<email>{{ . }}</email>
{{ end -}}
<name>{{ .Site.Title }}</name>
<uri>{{ "/" | absLangURL }}</uri>
</author>
<generator>Hugo gohugo.io</generator>
{{- with .Site.Copyright }}
<rights>{{ . }}</rights>
{{- end }}
{{ with site.Params.id }}
<id>{{ . | plainify }}</id>
{{ else }}
<id>{{ .Permalink }}</id>
{{ end }}
{{- $limit := (cond (le site.Config.Services.RSS.Limit 0) 65536 site.Config.Services.RSS.Limit) }}
{{- $feed_sections := site.Params.feedSections | default site.Params.mainSections -}}
{{/* Range through only the pages with a Type in $feed_sections. */}}
{{- $pages := where .RegularPages "Type" "in" $feed_sections -}}
{{- if (eq .Kind "home") -}}
{{- $pages = where site.RegularPages "Type" "in" $feed_sections -}}
{{- end -}}
{{/* Remove the pages that have the disable_feed parameter set to true. */}}
{{- $pages = where $pages ".Params.disable_feed" "!=" true -}}
{{- range first $limit $pages }}
{{ $page := . }}
<entry>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" />
{{- range .Translations }}
{{- $link := printf "%s?utm_source=atom_feed" .Permalink | safeHTML }}
{{- printf `<link href=%q rel="alternate" type="text/html" hreflang=%q />` $link .Lang | safeHTML }}
{{- with .Site.Params.brand.icon }}
<icon>{{ . | absURL }}</icon>
{{- end }}
{{/* rel=related: See https://validator.w3.org/feed/docs/atom.html#link */}}
{{- range first 5 (site.RegularPages.Related .) }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />
{{- with .Site.Params.brand.logo }}
<logo>{{ . | absURL }}</logo>
{{- end }}
{{ with .Params.id }}
<id>{{ . | plainify }}</id>
{{ else }}
<id>{{ .Permalink }}</id>
{{ end }}
{{ with .Params.author -}}
{{- range . -}} <!-- Assuming the author front-matter to be a list -->
<updated>{{ dateFormat "2006-01-02T15:04:05Z" now.UTC | safeHTML }}</updated>
{{- with .OutputFormats.Get "ATOM" }}
{{ printf `<link rel="self" type="%s" href="%s" hreflang="%s"/>` .MediaType.Type .Permalink $.Site.LanguageCode | safeHTML }}
{{- end }}
{{- range .AlternativeOutputFormats }}
{{ printf `<link rel="alternate" type="%s" href="%s" hreflang="%s"/>` .MediaType.Type .Permalink $.Site.LanguageCode | safeHTML }}
{{- end }}
{{- range $pages }}
<entry>
<title>{{ .Title }}</title>
{{- $author := index .Site.Data.authors (.Params.author | default "default") }}
<author>
<name>{{ . }}</name>
<name>{{ $author.name }}</name>
<uri>{{ $author.uri }}</uri>
</author>
<id>{{ .Permalink }}</id>
{{- if .IsTranslated -}}
{{ range .Translations }}
<link rel="alternate" href="{{ .Permalink }}" hreflang="{{ .Language.Lang }}"/>
{{- end -}}
{{- end }}
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ $description1 := .Description | default "" }}
{{ $description := (cond (eq "" $description1) "" (printf "<blockquote>%s</blockquote>" ($description1 | markdownify))) }}
{{ printf `<content type="html"><![CDATA[%s%s]]></content>` $description .Content | safeHTML }}
{{ with site.Taxonomies }}
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
{{ with $page.Param $taxo }}
{{ $taxo_list := . }} <!-- $taxo_list will be the tags/categories list -->
{{ 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="{{ . }}" />
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
<updated>{{ dateFormat "2006-01-02T15:04:05Z" .Lastmod.UTC | safeHTML }}</updated>
<published>{{ dateFormat "2006-01-02T15:04:05Z" .Date.UTC | safeHTML }}</published>
<content type="html">{{ trim .Content "\n" }}</content>
</entry>
{{ end }}
</feed>
{{- end }}
</feed>

108
themes/nipponalba/layouts/index.atom

@ -0,0 +1,108 @@
{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} {{/* ref: https://validator.w3.org/feed/docs/atom.html */}}
<feed xmlns="http://www.w3.org/2005/Atom"{{ with site.LanguageCode }} xml:lang="{{ . }}"{{ end }}>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
<link href="http://pubsubhubbub.superfeedr.com/" rel="hub"/>
{{- $title := site.Title -}}
{{- with .Title -}}
{{- if (not (eq . site.Title)) -}}
{{- $title = printf `%s %s %s` . (i18n "feed_title_on" | default "on") site.Title -}}
{{- end -}}
{{- end -}}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
{{ with (or (.Param "subtitle") (.Param "tagline")) }}
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
{{ end }}
{{ $output_formats := .OutputFormats }}
{{ range $output_formats -}}
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
{{ with $output_formats.Get .Name }}
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
{{- end -}}
{{- end }}
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ with site.Copyright }}
{{- $copyright := replace . "{year}" now.Year -}} {{/* In case the site.copyright uses a special string "{year}" */}}
{{- $copyright = replace $copyright "&copy;" "©" -}}
<rights>{{ $copyright | plainify }}</rights>
{{- end }}
{{ with .Param "feed" }}
{{/* For this to work, the $icon file should be present in the assets/ directory */}}
{{- $icon := .icon | default "icon.svg" -}}
{{- with resources.Get $icon -}}
<icon>{{ (. | fingerprint).Permalink }}</icon>
{{- end }}
{{/* For this to work, the $logo file should be present in the assets/ directory */}}
{{- $logo := .logo | default "logo.svg" -}}
{{- with resources.Get $logo -}}
<logo>{{ (. | fingerprint).Permalink }}</logo>
{{- end }}
{{ end }}
{{ with site.Author.name -}}
<author>
<name>{{ . }}</name>
{{ with site.Author.email }}
<email>{{ . }}</email>
{{ end -}}
</author>
{{- end }}
{{ with site.Params.id }}
<id>{{ . | plainify }}</id>
{{ else }}
<id>{{ .Permalink }}</id>
{{ end }}
{{- $limit := (cond (le site.Config.Services.RSS.Limit 0) 65536 site.Config.Services.RSS.Limit) }}
{{- $feed_sections := site.Params.feedSections | default site.Params.mainSections -}}
{{/* Range through only the pages with a Type in $feed_sections. */}}
{{- $pages := where .RegularPages "Type" "in" $feed_sections -}}
{{- if (eq .Kind "home") -}}
{{- $pages = where site.RegularPages "Type" "in" $feed_sections -}}
{{- end -}}
{{/* Remove the pages that have the disable_feed parameter set to true. */}}
{{- $pages = where $pages ".Params.disable_feed" "!=" true -}}
{{- range first $limit $pages }}
{{ $page := . }}
<entry>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" />
{{- range .Translations }}
{{- $link := printf "%s?utm_source=atom_feed" .Permalink | safeHTML }}
{{- printf `<link href=%q rel="alternate" type="text/html" hreflang=%q />` $link .Lang | safeHTML }}
{{- end }}
{{/* rel=related: See https://validator.w3.org/feed/docs/atom.html#link */}}
{{- range first 5 (site.RegularPages.Related .) }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="related" type="text/html" title="{{ .Title }}" />
{{- end }}
{{ with .Params.id }}
<id>{{ . | plainify }}</id>
{{ else }}
<id>{{ .Permalink }}</id>
{{ end }}
{{ with .Params.author -}}
{{- range . -}} <!-- Assuming the author front-matter to be a list -->
<author>
<name>{{ . }}</name>
</author>
{{- end -}}
{{- end }}
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ $description1 := .Description | default "" }}
{{ $description := (cond (eq "" $description1) "" (printf "<blockquote>%s</blockquote>" ($description1 | markdownify))) }}
{{ printf `<content type="html"><![CDATA[%s%s]]></content>` $description .Content | safeHTML }}
{{ with site.Taxonomies }}
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
{{ with $page.Param $taxo }}
{{ $taxo_list := . }} <!-- $taxo_list will be the tags/categories list -->
{{ 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="{{ . }}" />
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</entry>
{{ end }}
</feed>

2
themes/nipponalba/layouts/partials/head.html

@ -30,7 +30,7 @@
<link rel="icon" type="image/png" sizes="16x16" href="{{ .Site.Params.favicon | absURL }}favicon-16x16.png">
<link rel="manifest" href="{{ .Site.Params.favicon | absURL }}site.webmanifest">
<link rel="mask-icon" href="{{ .Site.Params.favicon | absURL }}safari-pinned-tab.svg" color="#5bbad5">
<link rel="alternate" type="application/atom+xml" href="http://jk.nipponalba.scot/atom.xml" rel="self" />
<link rel="alternate" type="application/atom+xml" href="http://jk.nipponalba.scot/feed.atom" rel="self" />
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
{{ if eq .Type "article" }}