From 87156110a680d237485ee7e7c9502833d21e7f7b Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Sun, 14 Aug 2022 14:45:13 +0800 Subject: [PATCH] :bug: Fix: author display error in post and markdown file --- CHANGELOG.md | 1 + layouts/_default/single.md | 7 ++++++- layouts/partials/single/post-author.html | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bc60ade..0b6bdbb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. - :sparkles: Feat: add custom aside template in post page ([#172](https://github.com/hugo-fixit/FixIt/issues/172)) - :bug: Fix: add function doc2unix to unify new lines symbol between Windows and Unix/Mac OS +- :bug: Fix: author display error in post and markdown file - :wrench: Chore: modify babel config and optimize theme.js compilation and loading - :wrench: Chore(deps-dev): - Remove minimist diff --git a/layouts/_default/single.md b/layouts/_default/single.md index 34e468ff..e4e990c3 100644 --- a/layouts/_default/single.md +++ b/layouts/_default/single.md @@ -1,4 +1,9 @@ {{- $params := .Scratch.Get "params" -}} +{{- $author := .Site.Author | merge (dict "name" "Anonymous" "link" (echoParam $params "authorlink")) -}} +{{- if isset $params "author" | and (ne $params.author .Site.Author.name) -}} + {{- $author = dict "name" $params.author | merge $author -}} + {{- $author = dict "link" (echoParam $params "authorlink") | merge $author -}} +{{- end -}} # {{ .Title }} {{ if $params.password -}} @@ -9,6 +14,6 @@ --- -> {{ T "author"}}: {{ .Site.Author.name }} +> {{ T "author"}}: {{ with $author.link }}[{{ $author.name }}]({{ . }}){{ else }}{{ $author.name }}{{ end }} > URL: {{ .Permalink }} {{ if $params.repost.enable | and (hasPrefix $params.repost.url "http") }}> {{ T "repost" }} URL: {{ $params.repost.url }}{{ end }} diff --git a/layouts/partials/single/post-author.html b/layouts/partials/single/post-author.html index 8b0b9c81..2740cceb 100644 --- a/layouts/partials/single/post-author.html +++ b/layouts/partials/single/post-author.html @@ -1,6 +1,6 @@ {{- $params := .Scratch.Get "params" -}} -{{- $author := .Site.Author | merge (dict "name" "" "link" (echoParam $params "authorlink") "email" (echoParam $params "authoremail")) -}} +{{- $author := .Site.Author | merge (dict "name" "Anonymous" "link" (echoParam $params "authorlink") "email" (echoParam $params "authoremail")) -}} {{- $avatar := .Site.Params.home.profile.avatarURL -}} {{- if isset $params "author" | and (ne $params.author .Site.Author.name) -}} {{- $author = dict "name" $params.author | merge $author -}}