Commit 6c250004 authored by Kaushal Modi's avatar Kaushal Modi

Move ATOM feed custom output format to a Hugo theme component repo

https://github.com/kaushalmodi/hugo-atom-feed
parent 18d9f8fe
......@@ -7,6 +7,7 @@ To use this theme, you need to clone this theme and the components too:
#+begin_example
cd HUGO_SITE_DIR/themes
git clone https://gitlab.com/kaushalmodi/hugo-theme-refined refined
git clone https://github.com/kaushalmodi/hugo-atom-feed hugo-atom-feed
git clone https://github.com/kaushalmodi/hugo-debugprint hugo-debugprint
#+end_example
* Theme variables
......
theme = ["hugo-debugprint", "refined"]
theme = ["hugo-debugprint", "hugo-atom-feed", "refined"]
# Custom Output Formats defined: "ATOM", "JF2Post", "JF2Feed"
# Atom feed
# Add "ATOM" to the Page Kinds under [outputs] (in your site config) for which
# you want to enable Atom feeds.
# Example:
# [outputs]
# home = ["HTML", "ATOM"]
# https://gist.github.com/lpar/7ded35d8f52fef7490a5be92e6cd6937
[mediaTypes."application/atom"]
suffix = "xml"
[outputFormats.Atom]
# https://validator.w3.org/feed/docs/atom.html#whatIsAtom
mediaType = "application/atom"
baseName = "atom" # generated file = <baseName>.<mediaType."application/atom".suffix> = atom.xml
isPlainText = false
# Custom Output Formats defined: "JF2Post", "JF2Feed"
# JF2 - https://www.w3.org/TR/jf2/
# JF2 post
......
{{/*
# Adding Atom feed
# https://gist.github.com/lpar/7ded35d8f52fef7490a5be92e6cd6937
[mediaTypes]
[mediaTypes."application/atom"]
suffix = "xml"
[outputFormats.Atom]
# https://validator.w3.org/feed/docs/atom.html#whatIsAtom
mediaType = "application/atom"
baseName = "atom" # generated file = <baseName>.<mediaType."application/atom".suffix> = atom.xml
isPlainText = false
[outputs]
home = ["HTML", "RSS", "ATOM"] # default = ["HTML", "RSS"]
*/}}
<feed xmlns="http://www.w3.org/2005/Atom">
<generator>Hugo -- gohugo.io</generator>
<title>
{{- with .Title -}}
{{- if (not (eq . $.Site.Title)) }}
{{ . }} on
{{ end }}
{{ end }}
{{ .Site.Title -}}
</title>
{{- with .OutputFormats.Get "atom" -}} <!-- Here, the Get is case-insensitive. -->
<link href="{{ .Permalink }}" rel="self" type="{{ .MediaType.Type }}+{{ .MediaType.Suffix }}" />
{{- end -}}
<link href="{{ .Permalink }}"/>
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ with .Site.Author.name -}}
<author>
<name>{{ . }}</name>
{{ with $.Site.Author.email }}
<email>{{ . }}</email>
{{ end -}}
</author>
{{- end }}
<id>{{ .Permalink }}</id>
{{- range (where .Pages "Type" "in" .Site.Params.mainSections) }}
{{ $page := . }}
<entry>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<link href="{{ .Permalink }}"/>
<id>{{ .Permalink }}</id>
{{ 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 "taxonomyTerm" $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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment