multi RSS hyperlink base on section and taxonomy

This commit is contained in:
leafee98 2022-05-16 20:41:20 +08:00
parent b343bac3f9
commit 715a82f5ac
2 changed files with 27 additions and 12 deletions

View file

@ -1,15 +1,21 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- if or $.IsHome -}}
{{/* remove page at top level from RSS, for exmaple "about" page */}}
{{- $pages = where $pctx.RegularPages "Type" "ne" "page" -}}
{{- else if $.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 }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>

View file

@ -1,18 +1,27 @@
<footer class="footer">
<div class="footer-row">
{{ if .IsHome }}
<a class="footer-item" href="{{ "/index.xml" | relURL }}">
The Site Feed
<i class="icofont-rss"></i>
</a>
{{ else }}
<a class="footer-item" href="{{ "/index.xml" | relURL }}">
The Site Feed
Feed of ALL
<i class="icofont-rss"></i>
</a>
{{ if gt (len .Site.Sections) 1 }}
{{ range .Site.Sections }}
{{ $page := . }}
{{ with .OutputFormats.Get "rss" }}
<a class="footer-item" href="{{ .Permalink }}">
The Taxonomy Feed
Feed of {{ with $page.Title }}{{ $page.Title }}{{ end }}
<i class="icofont-rss"></i>
</a>
{{ end }}
{{ end }}
{{ end }}
{{ if not (or .IsHome .IsSection) }}
{{ $page := . }}
{{ with .OutputFormats.Get "rss" }}
<a class="footer-item" href="{{ .Permalink }}">
Feed of "{{ with $page.Title }}{{ $page.Title }}{{ end }}"
<i class="icofont-rss"></i>
</a>
{{ end }}