Custom rss template

This commit is contained in:
Hazem Krimi
2023-11-20 19:13:04 +01:00
parent d963b389af
commit b70e0e9e93
6 changed files with 87 additions and 11 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
--- ---
title: "Home" title: 'Home'
date: 2023-10-18T20:03:43+01:00 date: 2023-10-18T20:03:43+01:00
--- ---
+2 -2
View File
@@ -1,6 +1,6 @@
--- ---
layout: "about" layout: 'about'
title: "About" title: 'About'
date: 2023-10-18T20:03:43+01:00 date: 2023-10-18T20:03:43+01:00
--- ---
+2 -2
View File
@@ -1,6 +1,6 @@
--- ---
layout: "contact" layout: 'contact'
title: "Contact" title: 'Contact'
date: 2023-10-18T20:03:43+01:00 date: 2023-10-18T20:03:43+01:00
--- ---
+1 -1
View File
@@ -18,4 +18,4 @@ This is a project that I made as a step in the interview process for my final ye
## Screenshots ## Screenshots
{{< figure src="https://res.cloudinary.com/dun9hhyz1/image/upload/v1643548378/personal-website/portfolio/react-weather-app/screenshot_ueu2a4.png" >}} {{< figure src="react-weather-app-screenshot.png" >}}
+1 -3
View File
@@ -1,12 +1,10 @@
languageCode = 'en-us' languageCode = 'en'
title = 'Hazem Krimi' title = 'Hazem Krimi'
paginate = 5 paginate = 5
enableRobotsTXT = true enableRobotsTXT = true
[outputs] [outputs]
home = ['html', 'rss'] home = ['html', 'rss']
section = ['html', 'rss'] section = ['html', 'rss']
taxonomy = ['html']
term = ['html']
[sitemap] [sitemap]
changeFreq = '' changeFreq = ''
filename = 'sitemap.xml' filename = 'sitemap.xml'
+78
View File
@@ -0,0 +1,78 @@
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
{{- $authorEmail := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .email }}
{{- $authorEmail = . }}
{{- end }}
{{- end }}
{{- else }}
{{- with site.Author.email }}
{{- $authorEmail = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }}
{{- end }}
{{- end }}
{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
{{- $authorName := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .name }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- with site.Author.name }}
{{- $authorName = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
{{- end }}
{{- end }}
{{- $projectsPages := where .Site.RegularPages "Section" "projects" }}
{{- $blogPages := where .Site.RegularPages "Section" "blog" }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $projectsPages = $projectsPages | first $limit }}
{{- $blogPages = $blogPages | 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>Hazem Krimi's content</title>
<link>{{ .Permalink }}</link>
<description>Hazem Krimi's projects and blog</description>
<generator>Hugo -- gohugo.io</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ 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 .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end }}
{{- range $projectsPages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Params.description | html }}</description>
</item>
{{- end }}
{{- range $blogPages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Params.description | html }}</description>
</item>
{{- end }}
</channel>
</rss>