diff options
author | Ngô Ngọc Đức Huy <huyngo@disroot.org> | 2023-08-30 17:05:49 +0700 |
---|---|---|
committer | Ngô Ngọc Đức Huy <huyngo@disroot.org> | 2023-08-30 17:06:17 +0700 |
commit | 601f0a3525d49665b2fb0e74032b332b7d5c9ae1 (patch) | |
tree | 76bc3946d745a572fb46c8176905387accdd89ac | |
parent | 70704b634dbb8b1ec71423ef88502ba667d91fb1 (diff) | |
download | victor-601f0a3525d49665b2fb0e74032b332b7d5c9ae1.tar.gz |
Add support for RSS
-rw-r--r-- | i18n/en.toml | 12 | ||||
-rw-r--r-- | layouts/_default/rss.xml | 34 | ||||
-rw-r--r-- | layouts/_default/taxonomy.html | 7 | ||||
-rw-r--r-- | layouts/_default/terms.html | 15 |
4 files changed, 68 insertions, 0 deletions
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 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> + <link>{{ .Permalink }}</link> + <description>{{ .Site.Title }}{{ if ne .Title .Site.Title }}{{ with .Title }} ({{.}}){{ end }}{{ end }}</description> + <generator>Hugo -- gohugo.io</generator>{{ 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 .OutputFormats.Get "RSS" }} + {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} + {{ end }} + {{ range $pages }} + <item> + <title>{{ .Title }}</title> + <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>{{ .Content | html }}</description> + </item> + {{ end }} + </channel> +</rss> 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" }} + <h1>{{ i18n .Data.Singular | humanize }}: {{ .Title }}</h1> + <div class="post-info"> + <a href="{{ (printf "%s/%s" .Site.LanguagePrefix .Data.Plural) | absLangURL }}">{{ i18n (printf "toAll%s" (.Data.Plural | humanize )) | humanize }}</a> + </div> + {{ 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" }} + <h1>{{ i18n .Title }}</h1> + + <ul class="terms"> + {{ range $key, $value := .Data.Terms }} + <li> + <a href="{{ (print $.Data.Plural "/" (lower $key)) | absLangURL }}"> + {{ $key }} + </a> + ({{ len $value }}) + </li> + {{ end }} + </ul> + +{{ end }} |