From 65dfecb5904d31968cf125648515e89937c24953 Mon Sep 17 00:00:00 2001 From: geekifan Date: Sat, 10 May 2025 12:03:05 +0800 Subject: [PATCH] feat: support i18n author and global author --- layouts/post/single.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/layouts/post/single.html b/layouts/post/single.html index a2893e2..5cde8e9 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -46,14 +46,19 @@
- {{ $authors := .Params.author | default .Params.authors }} + {{ $authors := .Params.author | default .Params.authors | default .Site.Params.author | default .Site.Params.authors }} + {{ if not (reflect.IsSlice $authors) }} + {{ $authors = slice $authors }} + {{ end }} + {{ $authorsData := index $.Site.Data.authors .Site.LanguageCode | default $.Site.Data.authors }} + {{ i18n "post.written_by" }} {{ if $authors }} {{ range $i, $author := $authors }} - {{ with $.Site.Data.authors }} + {{ with $authorsData }} {{ with (index . $author) }} {{ if .url }} {{ .name }}