Skip to content

Commit

Permalink
Improve RSS feed
Browse files Browse the repository at this point in the history
  • Loading branch information
pindab0ter committed Apr 5, 2024
1 parent f95ff7b commit b0fe894
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 109 deletions.
87 changes: 45 additions & 42 deletions hugo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
baseURL = 'https://hansvl.nl/'
languageCode = 'en-uk'
title = 'Hans van Luttikhuizen-Ross'
author = 'Hans van Luttikhuizen-Ross'
title = 'Hans'

pluralizelisttitles = false
paginate = 10
Expand All @@ -16,46 +15,50 @@ CanonifyURLs = true
series = "series"
tag = "tags"

[Params]
favicon = "favicon.ico"
titleImage = 'images/profile.jpg'
showPrevNextPostNavigation = true
showRecentPostsOnIndex = true

# Favicons config
# Get your favicons from https://realfavicongenerator.net/
[Params.favicons]
appleTouchIcon = '/apple-touch-icon.png'
icon32 = '/favicon-32x32.png'
icon16 = '/favicon-16x16.png'
manifest = '/site.webmanifest'
maskIcon = '/safari-pinned-tab.svg'
msApplicationTileColor = '#5bbad5'
themeColor = '#2B2B2B'

# Umami configuration
# https://umami.is/docs/install
[Params.umami]
enabled = true
websiteId = "88d855a7-4414-40a9-b228-1107ef60aca8"
jsLocation = "https://analytics.umami.is/script.js"

# Plausible configuration
[Params.plausible]
enabled = false
domain = "hansvl.nl"
jsLocation = "https://plausible.io/js/plausible.js"

# h-card configuration
# fullName is mandatory
[Params.hcard]
avatar = "images/profile.jpg"
fullName = "Hans van Luttikhuizen-Ross"
nickname = "pindab0ter"
showLocation = true
city = "Arnhem"
region = "Gelderland"
country = "The Netherlands"
[params]
favicon = "favicon.ico"
titleImage = 'images/profile.jpg'
showPrevNextPostNavigation = true
showRecentPostsOnIndex = true

[params.author]
name = 'Hans van Luttikhuizen-Ross'
email = '[email protected]'

# Favicons config
# Get your favicons from https://realfavicongenerator.net/
[params.favicons]
appleTouchIcon = 'apple-touch-icon.png'
icon32 = 'favicon-32x32.png'
icon16 = 'favicon-16x16.png'
manifest = 'site.webmanifest'
maskIcon = 'safari-pinned-tab.svg'
msApplicationTileColor = '#5bbad5'
themeColor = '#2B2B2B'

# Umami configuration
# https://umami.is/docs/install
[params.umami]
enabled = true
websiteId = "88d855a7-4414-40a9-b228-1107ef60aca8"
jsLocation = "https://analytics.umami.is/script.js"

# Plausible configuration
[params.plausible]
enabled = false
domain = "hansvl.nl"
jsLocation = "https://plausible.io/js/plausible.js"

# h-card configuration
# fullName is mandatory
[params.hcard]
avatar = "images/profile.jpg"
fullName = "Hans van Luttikhuizen-Ross"
nickname = "pindab0ter"
showLocation = true
city = "Arnhem"
region = "Gelderland"
country = "The Netherlands"

# Social icons to be displayed on the front page
[[menu.social]]
Expand Down
68 changes: 68 additions & 0 deletions layouts/_default/index.rss.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{- $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 }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ .Site.Title }}</title>
<link>{{ .Permalink }}</link>
<description>Recent posts on {{ .Site.Title }}</description>
{{ with .Site.LanguageCode }}<language>{{.}}</language>{{end}}
{{ with .Site.Copyright }}<copyright>{{.}}</copyright>{{end}}
<category>Software Development</category>
{{ with .Site.Params.favicons.appleTouchIcon }}
<image>
<url>{{ $.Site.BaseURL }}{{ . }}</url>
<title>{{ $.Title }}</title>
<link>{{ $.Permalink }}</link>
</image>
{{ end }}
<generator>Hugo -- gohugo.io</generator>
{{ with .Site.Params.author.email }}<managingEditor>{{.}}{{ with $.Site.Params.author.name }} ({{.}}){{end}}</managingEditor>{{end}}
{{ with .Site.Params.author.email }}<webMaster>{{.}}{{ with $.Site.Params.author.name }} ({{.}}){{end}}</webMaster>{{end}}
{{- with .OutputFormats.Get "RSS" -}}{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}{{- end -}}
{{ range $pages }}
{{ if eq .Type "blog" }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
{{ if not .Date.IsZero }}<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>{{ end }}
{{ if and (not (.Lastmod.IsZero)) (not (eq .Date .Lastmod)) }}<lastBuildDate>{{ .Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .Site.Params.author.name }}<author>{{.}}</author>{{end}}

{{ $content := .Content }}
<!-- relative images/URLs do not work in some feed readers. Thanks, Peter. See render-image.html -->
{{ $content = replaceRE `a href="(#.*?)"` (printf "%s%s%s" "a href=\"" .RelPermalink "$1\"") $content }}
{{ $content = replaceRE `a href="^../(.*?)"` (printf "%s%s%s" "a href=\"" .RelPermalink "../$1\"") $content }}
{{ $content = replaceRE `a href="/(.*?)"` (printf "%s%s%s" "a href=\"" $baseurl "$1\"") $content }}

<!-- Remove heading anchor links -->
{{ $content = replaceRE `(?s:<a[^>]*?class="link".*?<\/a>)` "" ($content | safeHTML) }}

<description>
{{- `<![CDATA[ ` | safeHTML -}}
{{- if and (.Params.cover) (not (in .Params.cover.src "http")) -}}
{{- $image := .Resources.GetMatch .Params.cover.src -}}
<p><img align="left" hspace="5" style="margin-bottom: 1rem;" src="{{- ($image.Resize "x550").Permalink -}}"/></p>
{{- else if (in .Params.cover.src "http") -}}
<p><img align="left" hspace="5" style="margin-bottom: 1rem;" src="{{ .Params.cover.src }}"/></p>
{{- end -}}
{{ $content | safeHTML }}
]]>
</description>

</item>
{{ end }}
{{ end }}
</channel>
</rss>
67 changes: 0 additions & 67 deletions layouts/_default/index.xml

This file was deleted.

0 comments on commit b0fe894

Please sign in to comment.