massively improve rss feeds

This commit is contained in:
Joshua Goins 2023-01-05 16:36:47 -05:00
parent 8b738af38e
commit 1d3112ec01
5 changed files with 116 additions and 45 deletions

BIN
assets/rss-image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -5,6 +5,7 @@ disableHugoGeneratorInject: true
enableGitInfo: true
enableRobotsTXT: true
languageCode: 'en-us'
summarylength: 15
minify:
tdewolff:
@ -24,6 +25,7 @@ params:
author:
name: 'redstrate'
email: 'josh@redstrate.com'
permalinks:
blog: 'blog/:year/:month/:title/'

View file

@ -16,25 +16,49 @@
xmlns:atom="http://www.w3.org/2005/Atom"
xml:base="{{ .Site.BaseURL }}">
<channel>
<title>{{ .Site.Author.name }}'s blog</title>
<title>{{ .Site.Author.name }}'s Blog</title>
<link>{{ .Permalink }}</link>
<description>My blog where I post about the things I like.</description>
{{ with .Site.LanguageCode }}<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<description>My blog where I post about the things I like and work on!</description>
{{ with .Site.LanguageCode }}<language>{{.}}</language>{{end}}
{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>
{{end}}
{{ 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 -}}
<docs>https://www.rssboard.org/rss-specification</docs>
{{ with resources.Get "rss-image.png" }}
<image>
<url>{{ .Permalink }}</url>
<title>{{ $.Site.Author.name }}'s Art</title>
<link>{{ $.Permalink }}</link>
<width>100</width>
<height>100</height>
</image>
{{ end }}
{{ range $pages }}
{{ if not (.Param "excludefeed") }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
{{ with $.Site.Author.name }}<author>{{ . }}</author>{{ end }}
{{ with $.Site.Author.name }}
<author>{{ . }}</author>
{{ end }}
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ "<![CDATA[" | safeHTML }} {{ .Summary }}]]></description>
<content:encoded>{{ "<![CDATA[" | safeHTML }} {{ partial "rss.html" . | safeHTML }}]]></content:encoded>

View file

@ -16,28 +16,74 @@
xmlns:atom="http://www.w3.org/2005/Atom"
xml:base="{{ .Site.BaseURL }}">
<channel>
<title>{{ .Site.Author.name }}'s art</title>
<title>{{ .Site.Author.name }}'s Art</title>
<link>{{ .Permalink }}</link>
<description>Feed of the art that I make!</description>
{{ with .Site.LanguageCode }}<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .Site.LanguageCode }}
<language>{{.}}</language>
{{end}}
{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>
{{end}}
{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
{{ end }}
<docs>https://www.rssboard.org/rss-specification</docs>
{{ with resources.Get "rss-image.png" }}
<image>
<url>{{ .Permalink }}</url>
<title>{{ $.Site.Author.name }}'s Art</title>
<link>{{ $.Permalink }}</link>
<width>100</width>
<height>100</height>
</image>
{{ end }}
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}}
{{ range $pages }}
{{ if not (.Param "excludefeed") }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>'
{{ with $.Site.Author.name }}<author>{{ . }}</author>{{ end }}
{{ with .Title }}
<title>{{ . }}</title>
{{ else }}
<title>Untitled Artwork</title>
{{ end }}
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{ "<![CDATA[" | safeHTML }} {{ .Summary }}]]></description>
<content:encoded>{{ "<![CDATA[" | safeHTML }} {{ partial "rss.html" . | safeHTML }}]]></content:encoded>
{{ with .Summary }}
<description>{{ "<![CDATA[" | safeHTML }} {{ . | safeHTML }}]]></description>
{{ else }}
<description>This artwork has no description.</description>
{{ end }}
{{ with $.Site.Author.name }}
<author>{{ . }}</author>
{{ end }}
<content:encoded>{{ "<![CDATA[" | safeHTML }}
{{ $pageScope := . }}
{{ with resources.Get .Params.filename }}
<img alt="{{ $pageScope.Params.alt_text }}" src="{{ .Permalink }}"/>
{{ end }}
{{ with .Content }}
<p>{{ . | safeHTML }}</p>
{{ else }}
<p>This artwork has no additional commentary.</p>
{{ end }}]]>
</content:encoded>
</item>
{{ end }}
{{ end }}

View file

@ -1,4 +1,3 @@
{{ $html := .Content | safeHTML }}
{{ $hrefs := findRE "href=\"([^\"]*)\"" $html }}