Compare commits

...
Author SHA1 Message Date
JimmyandGitHub 768e7de697 refactor: update RSS template to the latest one given by Hugo, and change page output logic (#1257)
* refactor: rename `home.rss.xml` to `rss.xml`

* refactor: update RSS template to the latest one given by Hugo.

Output pages with the same logic as in normal site by using `helper/pages`
2026-01-30 15:27:32 +01:00
JimmyandGitHub 00069b2c45 feat: add muted attribute and refine autoplay condition for video shortcode (#1256) 2026-01-30 15:09:33 +01:00
JimmyandGitHub 31022581d8 refactor: image logic in page (#1255)
* fix: add SVG check in helper/image before accessing .Width and .Height

* refactor: drop image resizing logic in render-image, and use helper/image to process image

* fix: render-image $permalink not correct
2026-01-30 15:07:14 +01:00
Jimmy Cai ff2e308445 fix: correct pluralization of 'minute' in English reading time. 2026-01-27 14:04:16 +01:00
JimmyandGitHub 017fbf982d chore: update Traditional Chinese localization files (#1251)
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/1222
2026-01-27 12:49:44 +01:00
8 changed files with 118 additions and 142 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ darkMode = "Dark Mode"
[article.readingTime]
one = "{{ .Count }} minute read"
other = "{{ .Count }} minute read"
other = "{{ .Count }} minutes read"
[notFound]
title = "Not Found"
+12 -21
View File
@@ -2,46 +2,37 @@ toggleMenu = "切換選單"
darkMode = "深色模式"
[list]
section = "Section"
[list.page]
one = "第 {{ .Count }} 頁"
other = "第 {{ .Count }} 頁"
[list.subsection]
one = "Subsection"
other = "Subsections"
page = "{{ .Count }} 篇文章"
section = "章節"
subsection = "子章節"
[article]
back = "返回"
tableOfContents = "目錄"
relatedContent = "相關內容"
lastUpdatedOn = "上次改過於"
[article.readingTime]
one = "需要 {{ .Count }} 分鐘閱讀"
other = "需要 {{ .Count }} 分鐘閱讀"
readingTime = "閱讀時間 {{ .Count }} 分鐘"
[notFound]
title = "Not Found"
subtitle = "頁面不存在"
title = "找不到頁面"
subtitle = "頁面不存在"
[widget]
[widget.archives]
title = "Archives"
title = "歸檔"
more = "更多"
[widget.tagCloud]
title = "Tags"
title = "標籤"
[widget.categoriesCloud]
title = "Categories"
title = "分類"
[search]
title = "搜尋"
placeholder = "Type 關鍵字..."
resultTitle = "#PAGES_COUNT pages (#TIME_SECONDS seconds)"
placeholder = "輸入關鍵字..."
resultTitle = "找到 #PAGES_COUNT 個結果 (用時 #TIME_SECONDS )"
[footer]
builtWith = "Built with {{ .Generator }}"
builtWith = "使用 {{ .Generator }} 建立"
designedBy = "主題 {{ .Theme }} 由 {{ .DesignedBy }} 設計"
+4 -13
View File
@@ -2,25 +2,16 @@ toggleMenu = "切換選單"
darkMode = "夜晚模式"
[list]
section = "段落"
[list.page]
one = "第 {{ .Count }} 頁"
other = "第 {{ .Count }} 頁"
[list.subsection]
one = "小節"
other = "小節"
section = "段落"
page = "第 {{ .Count }} 頁"
subsection = "小節"
[article]
back = "返回"
tableOfContents = "目錄"
relatedContent = "相關文章"
lastUpdatedOn = "最後更新"
[article.readingTime]
one = "閱讀時間: {{ .Count }} 分鐘"
other = "閱讀時間: {{ .Count }} 分鐘"
readingTime = "閱讀時間: {{ .Count }} 分鐘"
[notFound]
title = "404 錯誤"
+5 -27
View File
@@ -1,34 +1,12 @@
{{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}}
{{- $Permalink := .Destination | relURL | safeURL -}}
{{- $image := partial "helper/image" (dict "Resources" .Page.Resources "Image" .Destination) -}}
{{- $alt := .PlainText | safeHTML -}}
{{- $Width := 0 -}}
{{- $Height := 0 -}}
{{- $Srcset := "" -}}
{{/* SVG and external images won't work with gallery layout, because their width and height attributes are unknown */}}
{{- $galleryImage := false -}}
{{- $galleryImage := and $image.Height $image.Width -}}
{{- if $image -}}
{{- $notSVG := ne (path.Ext .Destination) ".svg" -}}
{{- $Permalink = $image.RelPermalink -}}
{{- if $notSVG -}}
{{- $Width = $image.Width -}}
{{- $Height = $image.Height -}}
{{- $galleryImage = true -}}
{{- if .Page.Site.Params.imageProcessing.content.enabled -}}
{{- $small := $image.Resize `480x` -}}
{{- $big := $image.Resize `1024x` -}}
{{- $Srcset = printf `%s 480w, %s 1024w` $small.RelPermalink $big.RelPermalink -}}
{{- end -}}
{{- end -}}
{{- end -}}
<img src="{{ $Permalink }}"
{{ with $Width }}width="{{ . }}"{{ end }}
{{ with $Height }}height="{{ . }}"{{ end }}
{{ with $Srcset }}srcset="{{ . }}"{{ end }}
<img src="{{ $image.Permalink }}"
{{ with $image.Width }}width="{{ . }}"{{ end }}
{{ with $image.Height }}height="{{ . }}"{{ end }}
loading="lazy"
{{ with $alt }}
alt="{{ . }}"
+28 -29
View File
@@ -9,45 +9,44 @@
/// Height: Image height
/// Width: Image width
{{ $result := dict
"Local" false
"Resource" nil
"Permalink" (.Image | absURL)
"Width" nil
"Height" nil
}}
{{ $result := "" }}
{{ if not .Image }}
{{ $result = "" }}
{{ else }}
{{ if .Image }}
{{ $url := urls.Parse .Image }}
{{ $resource := "" }}
{{ if not (in (slice "https" "http") $url.Scheme) }}
{{ $resource := .Resources.Get (printf "%s" (.Image | safeURL)) }}
{{ if $resource }}
{{ $resource = .Resources.Get (printf "%s" (.Image | safeURL)) }}
{{ else }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value }}
{{ $resource = . }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
{{ end }}
{{ if $resource }}
{{- $isSVG := eq $resource.MediaType.SubType "svg" -}}
{{- if $isSVG -}}
{{ $result = dict
"Local" true
"Resource" $resource
"Permalink" $resource.RelPermalink
"Height" nil
"Width" nil
}}
{{- else -}}
{{- $result = dict
"Local" true
"Resource" $resource
"Permalink" $resource.RelPermalink
"Height" $resource.Height
"Width" $resource.Width
}}
{{ end }}
{{ else }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value }}
{{ $result = dict
"Local" false
"Resource" .
"Permalink" .RelPermalink
"Height" .Height
"Width" .Width
}}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
{{- end -}}
{{ end }}
{{ end }}
+5 -4
View File
@@ -1,10 +1,11 @@
{{- $src := .Get "src" | default (.Get 0) -}}
<div class="video-wrapper">
<video
controls
src="{{- $src -}}"
{{ with .Get "poster" }}poster="{{- . -}}"{{ end }}
{{ with .Get "autoplay" }}autoplay{{ end }}
controls
src="{{- $src -}}"
{{ with .Get "poster" }}poster="{{- . -}}"{{ end }}
{{ if eq (.Get "autoplay") "true" }}autoplay{{ end }}
{{ if eq (.Get "muted") "true" }}muted{{ end }}
>
<p>
Your browser doesn't support HTML5 video. Here is a
-47
View File
@@ -1,47 +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 "<?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>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ 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 .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.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 }}
{{- $content := safeHTML (.Summary | html) -}}
{{- if .Site.Params.rssFullContent -}}
{{- $content = safeHTML (.Content | html) -}}
{{- end -}}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Params.Author.email }}<author>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>
{{- $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources) -}}
{{- if $image -}}
{{ "<" | html }}img src="{{ $image.permalink | absURL }}" alt="Featured image of post {{ .Title }}" {{ "/>" | html}}
{{- end -}}{{ $content }}</description>
</item>
{{ end }}
</channel>
</rss>
+63
View File
@@ -0,0 +1,63 @@
{{- $authorEmail := "" -}}
{{- with site.Params.author -}}
{{- if reflect.IsMap . -}}
{{- with .email -}}
{{- $authorEmail = . -}}
{{- end -}}
{{- end -}}
{{- end }}
{{- $authorName := "" -}}
{{- with site.Params.author -}}
{{- if reflect.IsMap . -}}
{{- with .name -}}
{{- $authorName = . -}}
{{- end -}}
{{- else -}}
{{- $authorName = . -}}
{{- end -}}
{{- end -}}
{{- $pages := partial "helper/pages.html" . -}}
{{- $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>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</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>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.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>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ .Permalink }}</guid>
<description>
{{- $content := .Summary -}}
{{- if .Site.Params.RSSFullContent -}}
{{- $content = .Content -}}
{{- end -}}
{{- $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources) -}}
{{- if $image -}}
{{- $imgTag := printf "<img src=\"%s\" alt=\"Featured image of post %s\" />" ($image.permalink | absURL) .Title -}}
{{- $content = printf "%s%s" $imgTag $content -}}
{{- end -}}
{{- $content | transform.XMLEscape | safeHTML -}}
</description>
</item>
{{- end -}}
</channel>
</rss>