Perf: add Gravatar config support

This commit is contained in:
Cell
2022-04-26 16:55:17 +08:00
parent bdc500b14c
commit 090583e437
5 changed files with 31 additions and 9 deletions
+2
View File
@@ -19,6 +19,8 @@ All notable changes to this project will be documented in this file.
- :sparkles: Feat: add GitHub Corners support ([#106](https://github.com/Lruihao/FixIt/issues/106))
- :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
> :warning: *The parameter `home.profile.gravatarSite` is deprecated since v0.2.14, use `params.gravatar.host` instead.*
- :bug: Fix: invalid front matter `comment: true` ([#108](https://github.com/Lruihao/FixIt/issues/108))
- :bug: Fix: ibruce and watermark option negative value error ([#114](https://github.com/Lruihao/FixIt/issues/114))
- :lipstick: Style: add some common CSS styles Class ([#101](https://github.com/Lruihao/FixIt/issues/101))
+7 -4
View File
@@ -170,8 +170,6 @@ enableEmoji = true
# Home page profile
[languages.en.params.home.profile]
enable = true
# Gravatar mirror site domain, default: "www.gravatar.com" since v0.2.13
gravatarSite = ""
# Gravatar Email for preferred avatar in home page
gravatarEmail = ""
# URL of avatar shown in home page
@@ -396,8 +394,6 @@ enableEmoji = true
# 主页个人信息
[languages.zh-cn.params.home.profile]
enable = true
# 选择使用 Gravatar 源站或其他镜像站,若留空则为默认的 "www.gravatar.com" since v0.2.13
gravatarSite = ""
# Gravatar 邮箱,用于优先在主页显示的头像
gravatarEmail = ""
# 主页显示头像的 URL
@@ -1102,6 +1098,13 @@ enableEmoji = true
enable = true
permalink = "https://github.com/Lruihao/FixIt"
title = "View source on GitHub"
# Gravatar config since v0.2.14
# Gravatar 设置 since v0.2.14
[params.gravatar]
# 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
# Markup related configuration in Hugo
# Hugo 解析文档的配置
@@ -333,7 +333,8 @@ Please open the code block below to view the complete sample configuration :(far
[params.home.profile]
enable = true
# {{< version 0.2.13 >}} Gravatar mirror site domain, default: "www.gravatar.com"
gravatarSite = ""
# {{< version 0.2.14 changed >}} {{< version 0.2.15 deleted >}} The parameter `home.profile.gravatarSite` is deprecated since v0.2.14, use `gravatar.host` instead
# gravatarSite = ""
# Gravatar Email for preferred avatar in home page
gravatarEmail = ""
# URL of avatar shown in home page
@@ -784,6 +785,11 @@ Please open the code block below to view the complete sample configuration :(far
enable = false
permalink = "https://github.com/Lruihao/FixIt"
title = "View source on GitHub"
# {{< version 0.2.14 >}} Gravatar config
[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
# Markup related configuration in Hugo
[markup]
@@ -343,7 +343,8 @@ hugo
[params.home.profile]
enable = true
# {{< version 0.2.13 >}} 选择使用 Gravatar 源站或其他镜像站,若留空则为默认的 "www.gravatar.com"
gravatarSite = ""
# {{< version 0.2.14 changed >}} {{< version 0.2.15 deleted >}} 参数 `home.profile.gravatarSite` 自 v0.2.14 起已弃用,请改用 `gravatar.host`
# gravatarSite = ""
# Gravatar 邮箱,用于优先在主页显示的头像
gravatarEmail = ""
# 主页显示头像的 URL
@@ -794,6 +795,11 @@ hugo
enable = false
permalink = "https://github.com/Lruihao/FixIt"
title = "在 GitHub 上查看源代码"
# {{< version 0.2.14 >}} Gravatar 设置
[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
# Hugo 解析文档的配置
[markup]
+8 -3
View File
@@ -2,9 +2,14 @@
<div class="home-profile">
{{- $avatar := $profile.avatarURL -}}
{{- if $profile.gravatarEmail -}}
{{- with $profile -}}
{{- $site := .gravatarSite | default "www.gravatar.com" -}}
{{- $avatar = md5 .gravatarEmail | printf "https://%v/avatar/%v?s=240&d=mp" $site -}}
{{- $gravatar := .Site.Params.gravatar -}}
{{- /* TODO: The parameter `home.profile.gravatarSite` will be deleted in v0.2.15 */ -}}
{{- with $gravatar -}}
{{- $avatar = printf "https://%v/avatar/%v?s=240&d=%v"
($profile.gravatarSite | default .Host | default "www.gravatar.com")
(md5 $profile.gravatarEmail)
(.Style | default "mp")
-}}
{{- end -}}
{{- end -}}
{{- if $avatar -}}