From 601f0a3525d49665b2fb0e74032b332b7d5c9ae1 Mon Sep 17 00:00:00 2001 From: Ngô Ngọc Đức Huy Date: Wed, 30 Aug 2023 17:05:49 +0700 Subject: Add support for RSS --- i18n/en.toml | 12 ++++++++++++ layouts/_default/rss.xml | 34 ++++++++++++++++++++++++++++++++++ layouts/_default/taxonomy.html | 7 +++++++ layouts/_default/terms.html | 15 +++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 layouts/_default/rss.xml create mode 100644 layouts/_default/taxonomy.html create mode 100644 layouts/_default/terms.html diff --git a/i18n/en.toml b/i18n/en.toml index 5ec68db..09bdcde 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -17,3 +17,15 @@ other = "Skip to main content" [toc] other = "Table of contents" + +[tags] +other = "tags" + +[tag] +other = "tag" + +[categories] +other = "categories" + +[category] +other = "category" diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml new file mode 100644 index 0000000..cb728d9 --- /dev/null +++ b/layouts/_default/rss.xml @@ -0,0 +1,34 @@ +{{- $pctx := . -}} +{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} +{{- $pages := where $pctx.RegularPages ".Params.disable_feed" "!=" true -}} +{{- $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 }} + {{ .Site.Title }}{{ if ne .Title .Site.Title }}{{ with .Title }} ({{.}}){{ end }}{{ 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 }} + + {{ .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 }} + + diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html new file mode 100644 index 0000000..ba80ec6 --- /dev/null +++ b/layouts/_default/taxonomy.html @@ -0,0 +1,7 @@ +{{ define "main" }} +

{{ i18n .Data.Singular | humanize }}: {{ .Title }}

+
+ {{ i18n (printf "toAll%s" (.Data.Plural | humanize )) | humanize }} +
+ {{ partial "generic-list.html" . }} +{{ end }} diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html new file mode 100644 index 0000000..81f400c --- /dev/null +++ b/layouts/_default/terms.html @@ -0,0 +1,15 @@ +{{ define "main" }} +

{{ i18n .Title }}

+ + + +{{ end }} -- cgit 1.4.1