feat: support i18n author and global author

This commit is contained in:
geekifan
2025-05-10 12:03:05 +08:00
parent 9b6309688f
commit 65dfecb590

View File

@ -46,14 +46,19 @@
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<!-- author(s) --> <!-- author(s) -->
<span> <span>
{{ $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" }} {{ i18n "post.written_by" }}
<em> <em>
{{ if $authors }} {{ if $authors }}
{{ range $i, $author := $authors }} {{ range $i, $author := $authors }}
{{ with $.Site.Data.authors }} {{ with $authorsData }}
{{ with (index . $author) }} {{ with (index . $author) }}
{{ if .url }} {{ if .url }}
<a href="{{ .url }}">{{ .name }}</a> <a href="{{ .url }}">{{ .name }}</a>