Skip to content

Commit 1a8ef06

Browse files
author
张天赐
committed
fix: 展示作者名称
1 parent 6cf3e08 commit 1a8ef06

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

layouts/partials/author.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- if or .Params.author site.Params.author }}
2+
{{- $author := (.Params.author | default site.Params.author) }}
3+
{{- $author_type := (printf "%T" $author) }}
4+
{{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }}
5+
{{- (delimit $author ", " ) }}
6+
{{- else }}
7+
{{- $author }}
8+
{{- end }}
9+
{{- end -}}

layouts/partials/post_meta.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
{{- $scratch := newScratch }}
2+
{{- $scratch.Set "meta" slice -}}
23

34
{{- $timeFormat := default "January 2, 2006" site.Params.DateFormat -}}
45

56
{{- if not .Date.IsZero -}}
67
{{- $rawDate := .Date.Format "2006-01-02T15:04:05Z07:00" -}}
78
{{- $formatted := .Date | time.Format $timeFormat -}}
89
{{- $text := printf (i18n "created_date") $formatted -}}
9-
{{- $html := printf `<span title="%s">%s</span>` $rawDate $text | safeHTML -}}
10-
{{- $scratch.Add "meta" (slice $html) -}}
10+
{{- $scratch.Add "meta" (printf `<span title="%s">%s</span>` $rawDate $text) -}}
1111
{{- end -}}
1212

1313
{{- if (.Param "ShowLastMod") -}}
1414
{{- $rawLastmod := .Lastmod.Format "2006-01-02T15:04:05Z07:00" -}}
1515
{{- $formatted := .Lastmod | time.Format $timeFormat -}}
1616
{{- $text := printf (i18n "modified_date") $formatted -}}
17-
{{- $html := printf `<span title="%s">%s</span>` $rawLastmod $text | safeHTML -}}
18-
{{- $scratch.Add "meta" (slice $html) -}}
19-
{{- end }}
17+
{{- $scratch.Add "meta" (printf `<span title="%s">%s</span>` $rawLastmod $text) -}}
18+
{{- end -}}
2019

2120
{{- if (.Param "ShowReadingTime") -}}
2221
{{- $scratch.Add "meta" (slice (i18n "read_time" .ReadingTime | default (printf "%d min" .ReadingTime))) }}
@@ -34,4 +33,4 @@
3433

3534
{{- with ($scratch.Get "meta") }}
3635
{{- delimit . "&nbsp;·&nbsp;" | safeHTML -}}
37-
{{- end -}}
36+
{{- end -}}

0 commit comments

Comments
 (0)