aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/rss.xml
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/_default/rss.xml')
-rw-r--r--themes/default/layouts/_default/rss.xml124
1 files changed, 98 insertions, 26 deletions
diff --git a/themes/default/layouts/_default/rss.xml b/themes/default/layouts/_default/rss.xml
index a09f9bf..16aee5f 100644
--- a/themes/default/layouts/_default/rss.xml
+++ b/themes/default/layouts/_default/rss.xml
@@ -1,40 +1,112 @@
-{{- $pctx := . -}}
-{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
-{{- $pages := $pctx.RegularPages -}}
+{{- define "main" -}}
+
+{{- $absURL := "" | absURL -}}
+
{{- $limit := .Site.Config.Services.RSS.Limit -}}
-{{- if ge $limit 1 -}}
-{{- $pages = $pages | first $limit -}}
+
+{{- if lt $limit 1 -}}
+ {{- $limit = .Paginator.TotalNumberOfElements -}}
+{{- end -}}
+
+{{- $lastBuildDate := now | time.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}}
+
+{{- if not .Date.IsZero -}}
+ {{- $lastBuildDate = .Date | time.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML -}}
+{{- end -}}
+
+{{- $title := partial "head-title.html" . -}}
+{{- $description := partial "head-title.html" . -}}
+{{- $author := partial "function-authors-data.html" . -}}
+{{- $image := print "/favicon.ico" -}}
+
+{{- if (eq .Page.Kind "section") -}}
+ {{- $title = $author.name -}}
+ {{- $description = $author.description | markdownify | html | htmlUnescape -}}
+ {{- $image = print "/" (partial "function-paths.html").media "/" .Section "/" .Section "-profile" (path.Ext $author.picture.profile) -}}
+{{- end -}}
+
+{{- if (eq .Page.Type "tags") -}}
+ {{- $title = print "#" (lower .Title) " -- " .Site.Title | markdownify | htmlUnescape -}}
+ {{- $description = print .Site.Title " Tags: #" .Title -}}
{{- end -}}
-{{- print "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
-{{- print "<?xml-stylesheet href=\"/rss.xsl\" type=\"text/xsl\"?>" | safeHTML }}
-<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+{{- $atomSelf := "" -}}
+{{- $atomPrevious := "" -}}
+{{- $atomNext := "" -}}
+
+{{- with .OutputFormats.Get "RSS" -}}
+ {{- $atomSelf = printf `<atom:link rel="self" href=%q type=%q />` .Permalink .MediaType | safeHTML -}}
+
+ {{- with $.Paginator.Prev -}}
+ {{- $atomPrevious = printf `<atom:link rel="previous" href=%q />` (.URL | absURL) | safeHTML -}}
+ {{- end -}}
+
+ {{- with $.Paginator.Next -}}
+ {{- $atomNext = printf `<atom:link rel="next" href=%q />` (.URL | absURL) | safeHTML -}}
+ {{- end -}}
+{{- end -}}
+
+{{- $filteredPages := partial "function-filters-content.html" .Paginator.Pages -}}
+
+{{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }}
+{{ printf `<?xml-stylesheet href="/rss.xsl" type="text/xsl"?>` | safeHTML }}
+
+<rss
+ version="2.0"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+>
<channel>
- <title>{{ partial "site-title" . }}</title>
+ <title>{{ or $title (title .Section) }}</title>
<link>{{ .Permalink }}</link>
- <description>Recent from {{ partial "site-title" . }}</description>
+ <description>{{ $description }}</description>
<language>{{ .Site.LanguageCode }}</language>
- <category>{{ partial "author-user" . }}</category>
+ <category>{{ or $author.user "default" }}</category>
+ <generator>Hugo {{ hugo.Version }}</generator>
+ <lastBuildDate>{{ $lastBuildDate }}</lastBuildDate>
<image>
- <title>{{ partial "site-title" . }}</title>
- <url>{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}/profile/picture.png</url>
+ <title>{{ $title }}</title>
+ <url>{{ $absURL }}{{ $image }}</url>
<link>{{ .Permalink }}</link>
</image>
- {{ if not .Date.IsZero -}}
- <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
- {{ with .OutputFormats.Get "RSS" }}
- {{- printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML -}}
- {{ end }}
- {{- range $pages -}}
- {{ if and (not .Params.Unlisted) (not .ExpiryDate) }}
+
+ {{ $atomSelf }}
+ {{ $atomPrevious }}
+ {{ $atomNext }}
+
+ {{ range first $limit $filteredPages -}}
+
+ {{- $author = partial "function-authors-data.html" . -}}
+
+ {{- $image = print "/" (partial "function-paths.html").media
+ "/" $author.user "/" $author.user "-profile" (path.Ext $author.picture.profile)
+ -}}
+
+ {{- $atomAuthorUri := print $absURL $image -}}
+ {{- $atomAuthorName := or .Params.Feed.name $author.name -}}
+
+ {{- if .Params.Feed.favicon -}}
+ {{- $favicon := print "/" (partial "function-paths.html").media "/favicon." (.Params.Feed.source | anchorize) ".png" -}}
+ {{- $atomAuthorUri = print $absURL $favicon -}}
+ {{- end -}}
+
<item>
- <title>{{ .Summary | htmlUnescape }}</title>
- <link>{{ .Permalink }}</link>
- <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
+ <title>{{ (or .Summary .Title) | htmlUnescape }}</title>
+ <link>{{ or .Params.Feed.link .Permalink }}</link>
+ <pubDate>{{ .Date | time.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<guid>{{ .Permalink }}</guid>
- <description>{{ .Content | html }}</description>
+ <description>
+ {{ partial "function-content.html" . | html -}}
+ {{- print "<br /><br />" | html -}}
+ {{- printf `<a href=%q>Permalink</a>&nbsp;` .Permalink | html }}
+ {{ partial "tags.html" (dict "Format" "rss" "Context" .) | html }}
+ </description>
+ <atom:author>
+ <atom:name>{{ $atomAuthorName }}</atom:name>
+ <atom:uri>{{ $atomAuthorUri }}</atom:uri>
+ </atom:author>
</item>
- {{ end }}
- {{ end }}
+
+ {{ end -}}
</channel>
</rss>
+{{- end -}}