From 90773292d74d75cbce10108c89947bb1659da7d6 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 10 Jul 2023 17:34:19 +0530 Subject: [PATCH] refactor: update RSS output template --- config.toml | 1 + layouts/_default/rss.xml | 51 ++++++++++++++++++++++++++++++++++++++++ layouts/index.xml | 39 ------------------------------ 3 files changed, 52 insertions(+), 39 deletions(-) create mode 100644 layouts/_default/rss.xml delete mode 100644 layouts/index.xml diff --git a/config.toml b/config.toml index 9c14798..d875a10 100644 --- a/config.toml +++ b/config.toml @@ -57,6 +57,7 @@ enableEmoji = true showBreadCrumbs = true showCodeCopyButtons = true showRssButtonInSectionTermList = true + ShowFullTextinRSS = true showToc = true [params.editPost] diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml new file mode 100644 index 0000000..d942d6c --- /dev/null +++ b/layouts/_default/rss.xml @@ -0,0 +1,51 @@ +{{- $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 "" | safeHTML }} + + + {{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ site.Title }}{{ end }} + {{ .Permalink }} + Recent content {{ if ne .Title site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ site.Title }} + {{- with site.Params.images }} + + {{ site.Title }} + {{ index . 0 | absURL }} + {{ index . 0 | absURL }} + + {{- end }} + Hugo -- gohugo.io{{ with site.LanguageCode }} + {{.}}{{end}}{{ with site.Author.email }} + {{.}}{{ with site.Author.name }} ({{.}}){{end}}{{end}}{{ with site.Author.email }} + {{.}}{{ with site.Author.name }} ({{.}}){{end}}{{end}}{{ with site.Copyright }} + {{.}}{{end}}{{ if not .Date.IsZero }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{- with .OutputFormats.Get "RSS" -}} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end -}} + {{ range $pages }} + {{- if and (and (ne .Layout `search`) (ne .Layout `archives`)) (ne .Type "page") }} + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ with site.Author.email }}{{.}}{{ with site.Author.name }} ({{.}}){{end}}{{end}} + {{ .Permalink }} + {{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}} + {{- if site.Params.ShowFullTextinRSS }} + {{ (printf "" .Content) | safeHTML }} + {{- end }} + + {{- end }} + {{ end }} + + diff --git a/layouts/index.xml b/layouts/index.xml deleted file mode 100644 index e49c966..0000000 --- a/layouts/index.xml +++ /dev/null @@ -1,39 +0,0 @@ -{{- $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 "" | safeHTML }} - - - {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} - {{ .Permalink }} - Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} - Hugo -- gohugo.io{{ with .Site.LanguageCode }} - {{.}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} - {{.}}{{end}}{{ if not .Date.IsZero }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - {{- with .OutputFormats.Get "RSS" -}} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{- end -}} - {{ range $pages }} - - {{ .Title }} - {{ .Permalink }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} - {{ .Permalink }} - {{ .Content | html }} - - {{ end }} - -