mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-09-03 04:02:40 +00:00
7ff750ab0a
1. `params.profile.gravatarEmail` only takes effect when `params.gravatar.enable=true` 2. Adjust frontmatter: `author` data type from string to **map** 3. Remove frontmatter: `gravatarForce`, `authorLink`, `authorEmail` 4. Add frontmatter: `authorAvatar` 5. Add `params.gravatar.enable`
53 lines
2.0 KiB
HTML
53 lines
2.0 KiB
HTML
{{- $params := .Scratch.Get "params" -}}
|
|
{{- $authorDefault := dict "name" "Anonymous" "link" "" "email" "" "avatar" "" -}}
|
|
{{- $author := .Site.Author | merge $authorDefault -}}
|
|
{{- $authorPost := dict -}}
|
|
{{- $gravatar := .Site.Params.gravatar -}}
|
|
|
|
{{- if $params.authorAvatar -}}
|
|
{{- if reflect.IsMap $params.author -}}
|
|
{{- $authorPost = $params.author -}}
|
|
{{- else if isset $params "author" -}}
|
|
{{- $authorPost = dict "name" $params.author -}}
|
|
{{- end -}}
|
|
{{- if isset $authorPost "name" | and (ne $authorPost.name .Site.Author.name) -}}
|
|
{{- $author = $authorPost | merge $authorDefault | merge $author -}}
|
|
{{- else -}}
|
|
{{- with $authorPost.link -}}{{- $author = dict "link" . | merge $author -}}{{- end -}}
|
|
{{- with $authorPost.email -}}{{- $author = dict "email" . | merge $author -}}{{- end -}}
|
|
{{- with $authorPost.avatar -}}{{- $author = dict "avatar" . | merge $author -}}{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if $gravatar.enable | and $author.email -}}
|
|
{{- with $gravatar -}}
|
|
{{- $author = dict "avatar" (printf "https://%v/avatar/%v?s=32&d=%v"
|
|
(path.Clean .Host | default "www.gravatar.com")
|
|
(md5 $author.email)
|
|
(.Style | default ""))
|
|
| merge $author
|
|
-}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
<span class="post-author">
|
|
{{- $content := $author.name -}}
|
|
{{- $icon := dict "Class" "fa-solid fa-user-circle" -}}
|
|
{{- if $author.avatar | and $params.authorAvatar -}}
|
|
{{- $content = printf "%v %v" (dict "Src" $author.avatar "Class" "avatar" "Alt" $author.name | partial "plugin/image.html") $author.name -}}
|
|
{{- $icon = "" -}}
|
|
{{- end -}}
|
|
{{- if $author.link -}}
|
|
{{- $options := dict "Class" "author" "Destination" $author.link "Title" (T "single.author") "Rel" "author" "Icon" $icon "Content" $content -}}
|
|
{{- partial "plugin/link.html" $options -}}
|
|
{{- else -}}
|
|
<span class="author">
|
|
{{- with $icon -}}
|
|
{{- . | partial "plugin/icon.html" }}
|
|
{{ end -}}
|
|
{{- $content | safeHTML -}}
|
|
</span>
|
|
{{- end -}}
|
|
</span>
|
|
{{- /* EOF */ -}}
|