Skip to content

Commit

Permalink
Adds filter to RSS feed to remove bookmarks and tools
Browse files Browse the repository at this point in the history
  • Loading branch information
errbufferoverfl committed Aug 12, 2023
1 parent cfbf994 commit 6afa8e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions layouts/_default/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- $pages = (where $pages ".Params.tags" "!=" "bookmark") -}}
{{- $pages = (where $pages ".Params.unlisted" "!=" "true") -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- printf "<?xml-stylesheet href=\"/rss.xsl\" type=\"text/xsl\"?>" | safeHTML }}
Expand All @@ -26,17 +25,20 @@
<rights>{{.}}</rights>{{end}}{{ if not .Date.IsZero }}
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>{{ end }}
{{ with .OutputFormats.Get "RSS" }}{{ end }}{{ range $pages }}
{{ if (and (not (in .Params.tags "bookmark")) (not (in .Params.tags "tool"))) }}
<entry>
<title>{{ .Title }}</title>
<link rel="alternate" type="text/html" href="{{ .Permalink }}"/>
<published>{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}</updated>
<summary>{{ .Summary | html }}</summary>
<tags>{{.Params.tags}}</tags>
<id>{{ .Permalink }}</id>{{ with .Site.Author.name }}
<author>
<name>{{.}}</name>
</author>
{{end}}
{{ end }}
</entry>
{{ end }}
{{ end }}
</feed>
3 changes: 3 additions & 0 deletions static/rss.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

<main class="container">
<h2>Recent blog posts</h2>

<xsl:for-each select="/atom:feed/atom:entry">
<article>
<h3>
Expand All @@ -56,6 +57,8 @@
<xsl:value-of select="atom:title"/>
</a>
</h3>
<p>
<xsl:value-of select="atom:tags"/></p>
<footer>
<p>Published on <xsl:value-of select="substring(atom:published, 0, 11)"/></p>
</footer>
Expand Down

0 comments on commit 6afa8e0

Please sign in to comment.