mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
✨ Feat: add local avatar and gravatar support for post author (#125)
This commit is contained in:
@@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Add download icon for downloadable links
|
||||
- :sparkles: Feat: link shortcode add `external-icon` option ([#96](https://github.com/Lruihao/FixIt/issues/96))
|
||||
- :sparkles: Feat: add GitHub Corners support ([#106](https://github.com/Lruihao/FixIt/issues/106))
|
||||
- :sparkles: Feat: add local avatar and gravatar support for post author ([#125](https://github.com/Lruihao/FixIt/issues/125))
|
||||
- :sparkles: Feat: add "Edit this page" button support ([#103](https://github.com/Lruihao/FixIt/issues/103))
|
||||
- :sparkles: Feat: add count badge for taxonomy ([#122](https://github.com/Lruihao/FixIt/issues/122))
|
||||
- :zap: Perf: add Gravatar config support
|
||||
|
||||
@@ -33,6 +33,21 @@
|
||||
|
||||
.author {
|
||||
font-size: 1.05rem;
|
||||
|
||||
img.avatar {
|
||||
width: 1.3rem;
|
||||
height: 1.3rem;
|
||||
border-radius: 50%;
|
||||
vertical-align: text-bottom;
|
||||
border: 0.25px solid $global-border-color;
|
||||
box-sizing: border-box;
|
||||
object-position: center;
|
||||
@include object-fit(cover);
|
||||
|
||||
[theme='dark'] & {
|
||||
border-color: $global-border-color-dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -508,6 +508,11 @@ enableEmoji = true
|
||||
enable = true
|
||||
permalink = "https://github.com/Lruihao/FixIt"
|
||||
title = "在 GitHub 上查看源代码"
|
||||
# Gravatar 设置 since v0.2.14
|
||||
[languages.zh-cn.params.gravatar]
|
||||
# Gravatar 主机,默认:“www.gravatar.com”
|
||||
host = "gravatar.loli.net"
|
||||
style = "mp" # "", mp, identicon, monsterid, wavatar, retro, blank, robohash
|
||||
|
||||
[params]
|
||||
# FixIt theme version
|
||||
@@ -670,6 +675,9 @@ enableEmoji = true
|
||||
# Page style ("narrow", "normal", "wide", ...) since v0.2.13
|
||||
# 页面样式 ("narrow", "normal", "wide", ...) since v0.2.13
|
||||
pageStyle = "normal"
|
||||
# Gravatar is force-used as the author's avatar since v0.2.14
|
||||
# 强制使用 Gravatar 作为作者头像 since v0.2.14
|
||||
gravatarForce = true
|
||||
# Table of the contents config
|
||||
# 目录配置
|
||||
[params.page.toc]
|
||||
@@ -1104,7 +1112,7 @@ enableEmoji = true
|
||||
# Gravatar host, default: "www.gravatar.com"
|
||||
# Gravatar 主机,默认:“www.gravatar.com”
|
||||
host = "www.gravatar.com" # "cn.gravatar.com", "gravatar.loli.net"
|
||||
# style = "mp" # "", mp, identicon, monsterid, wavatar, retro, blank, robohash
|
||||
style = "mp" # "", mp, identicon, monsterid, wavatar, retro, blank, robohash
|
||||
|
||||
# Markup related configuration in Hugo
|
||||
# Hugo 解析文档的配置
|
||||
|
||||
@@ -453,6 +453,8 @@ Please open the code block below to view the complete sample configuration :(far
|
||||
rssFullText = false
|
||||
# {{< version 0.2.13 >}} Page style ("narrow", "normal", "wide", ...)
|
||||
pageStyle = "normal"
|
||||
# {{< version 0.2.14 >}} Gravatar is force-used as the author's avatar
|
||||
gravatarForce = false
|
||||
# {{< version 0.2.0 >}} Table of the contents config
|
||||
[params.page.toc]
|
||||
# whether to enable the table of the contents
|
||||
@@ -786,7 +788,7 @@ Please open the code block below to view the complete sample configuration :(far
|
||||
[params.gravatar]
|
||||
# Gravatar host, default: "www.gravatar.com"
|
||||
host = "www.gravatar.com" # "cn.gravatar.com", "gravatar.loli.net"
|
||||
style = "mp" # "", mp, identicon, monsterid, wavatar, retro, blank, robohash
|
||||
style = "" # "", mp, identicon, monsterid, wavatar, retro, blank, robohash
|
||||
|
||||
# Markup related configuration in Hugo
|
||||
[markup]
|
||||
|
||||
@@ -463,6 +463,8 @@ hugo
|
||||
rssFullText = false
|
||||
# {{< version 0.2.13 >}} 页面样式 ("narrow", "normal", "wide", ...)
|
||||
pageStyle = "normal"
|
||||
# {{< version 0.2.14 >}} 强制使用 Gravatar 作为作者头像
|
||||
gravatarForce = true
|
||||
# {{< version 0.2.0 >}} 目录配置
|
||||
[params.page.toc]
|
||||
# 是否使用目录
|
||||
@@ -796,7 +798,7 @@ hugo
|
||||
[params.gravatar]
|
||||
# Gravatar 主机,默认:“www.gravatar.com”
|
||||
host = "www.gravatar.com" # "cn.gravatar.com", "gravatar.loli.net"
|
||||
style = "mp" # "", mp, identicon, monsterid, wavatar, retro, blank, robohash
|
||||
style = "" # "", mp, identicon, monsterid, wavatar, retro, blank, robohash
|
||||
|
||||
# Hugo 解析文档的配置
|
||||
[markup]
|
||||
|
||||
@@ -24,12 +24,7 @@
|
||||
|
||||
{{- /* Meta */ -}}
|
||||
<div class="post-meta">
|
||||
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
|
||||
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
|
||||
<span class="post-author">
|
||||
{{- $options := dict "Class" "author" "Destination" $authorLink "Title" "Author" "Rel" "author" "Icon" (dict "Class" "fas fa-user-circle fa-fw") "Content" $author -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
</span>
|
||||
{{- partial "single/post-author.html" . -}}
|
||||
|
||||
{{- with .Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format -}}
|
||||
<span class="post-publish" title='{{ "2006-01-02 15:04:05" | $.PublishDate.Format }}'>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
{{- $params := .Scratch.Get "params" -}}
|
||||
|
||||
{{- $author := .Site.Author | merge (dict "name" "" "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 -}}
|
||||
{{- $author = dict "link" (echoParam $params "authorlink") | merge $author -}}
|
||||
{{- $author = dict "email" (echoParam $params "authoremail") | merge $author -}}
|
||||
{{- $avatar = "" -}}
|
||||
{{- end -}}
|
||||
{{- if (not $avatar | or $params.gravatarForce) | and $author.email -}}
|
||||
{{- $gravatar := .Site.Params.gravatar -}}
|
||||
{{- with $gravatar -}}
|
||||
{{- $avatar = printf "https://%v/avatar/%v?s=32&d=%v" (.Host | default "www.gravatar.com") (md5 $author.email) (.Style | default "") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<span class="post-author">
|
||||
{{- $content := $author.name -}}
|
||||
{{- $icon := dict "Class" "fas fa-user-circle" -}}
|
||||
{{- if $avatar -}}
|
||||
{{- $content = printf "%v %v" (dict "Src" $avatar "Class" "avatar" | partial "plugin/image.html") $author.name -}}
|
||||
{{- $icon = "" -}}
|
||||
{{- end -}}
|
||||
{{- if $author.link -}}
|
||||
{{- $options := dict "Class" "author" "Destination" $author.link "Title" (T "author") "Rel" "author" "Icon" $icon "Content" $content -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
{{- else -}}
|
||||
<span class="author">
|
||||
{{- with $icon -}}
|
||||
<i class="{{ .Class }}"></i>
|
||||
{{ end -}}
|
||||
{{- $content | safeHTML -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
</span>
|
||||
@@ -29,12 +29,7 @@
|
||||
{{- /* Meta */ -}}
|
||||
<div class="post-meta">
|
||||
<div class="post-meta-line">
|
||||
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
|
||||
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
|
||||
<span class="post-author">
|
||||
{{- $options := dict "Class" "author" "Destination" $authorLink "Title" "Author" "Rel" "author" "Icon" (dict "Class" "fas fa-user-circle fa-fw") "Content" $author -}}
|
||||
{{- partial "plugin/link.html" $options -}}
|
||||
</span>
|
||||
{{- partial "single/post-author.html" . -}}
|
||||
|
||||
{{- $categories := slice -}}
|
||||
{{- range .Params.categories -}}
|
||||
|
||||
Reference in New Issue
Block a user