added atom feed for gemini site

This commit is contained in:
Michael Clemens 2021-07-18 10:23:12 +02:00
parent 3e86c92b6e
commit dd0b775805
2 changed files with 53 additions and 2 deletions

View File

@ -10,7 +10,9 @@ publishDir = "/var/www/qrz.is"
[mediaTypes]
[mediaTypes."text/gemini"]
suffixes = ["gmi"]
suffixes = ["gmi"]
[mediaTypes."application/atom"]
suffixes= ["xml"]
[outputFormats]
@ -22,9 +24,17 @@ suffixes = ["gmi"]
protocol = "gemini://"
permalinkable = true
path ="gemini/"
[outputFormats.gemini_atom]
name = "GEMINI_ATOM"
isPlainText = true
isHTML = false
baseName = "atom"
path = "gemini/"
protocol = "gemini://"
mediaType = "application/atom"
[outputs]
home = ["HTML", "RSS", "GEMINI"]
home = ["HTML", "GEMINI_ATOM", "GEMINI"]
page = ["HTML", "GEMINI"]
# Menu links

View File

@ -0,0 +1,41 @@
{{- $allowedRssSections := (slice "post") -}}
{{- $baseurl := .Site.BaseURL -}}
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $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="en">
<title>{{ .Site.Title }}</title>
{{- $perm := replace .Permalink "/gemini" "" 1 -}}
{{- $alt := .Site.BaseURL | replaceRE `https?://(.+?)` "gemini://$1" -}}
{{ printf "<link rel=\"self\" type=\"application/atom+xml\" href=\"%s\"/>" $perm | safeHTML }}
{{ printf "<link rel=\"alternate\" type=\"text/html\" href=\"%s\"/>" $alt | safeHTML }}
<updated>{{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }}</updated>
<author>
<name>{{ .Site.Author.name }}</name>
<uri>{{ .Site.BaseURL | replaceRE `https?://(.+?)` "gemini://$1" }}</uri>
</author>
<id>{{ $perm }}</id>
{{ range $pages }}
{{ if in $allowedRssSections .Section }}
<entry>
<title>{{ .Title }}</title>
{{- $entryperm := .Permalink | replaceRE `https?://(.+?)` "gemini://$1" -}}
{{ printf "<link rel=\"alternate\" href=\"%s\"/>" $entryperm | safeHTML }}
<id>{{ $entryperm }}</id>
<published>{{ .Date.Format "2006-01-02T15:04:05-0700" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-0700" | safeHTML }}</updated>
<summary>{{ if isset .Params "subtitle" }}{{ .Params.subtitle }}{{ else }}{{ .Summary | html }}{{ end }}</summary>
</entry>
{{ end }}
{{ end }}
</feed>