Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] add Gravatar mirror site support #66

Merged
merged 2 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ enableEmoji = true
# Home page profile
[languages.en.params.home.profile]
enable = true
# Gravarar mirror site domain, when empty www.gravatar.com will be used
gravatarSite = ""
# Gravatar Email for preferred avatar in home page
gravatarEmail = ""
# URL of avatar shown in home page
Expand Down Expand Up @@ -375,6 +377,8 @@ enableEmoji = true
# 主页个人信息
[languages.zh-cn.params.home.profile]
enable = true
# 选择使用 Gravatar 源站或其他镜像站,若留空则为默认的 www.gravatar.com
gravatarSite = ""
# Gravatar 邮箱,用于优先在主页显示的头像
gravatarEmail = ""
# 主页显示头像的 URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ Please open the code block below to view the complete sample configuration :(far
# Home page profile
[params.home.profile]
enable = true
# Gravarar mirror site domain, when empty, www.gravatar.com will be used
gravatarSite = ""
# Gravatar Email for preferred avatar in home page
gravatarEmail = ""
# URL of avatar shown in home page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ hugo
# 主页个人信息
[params.home.profile]
enable = true
# 选择使用 Gravatar 源站或其他镜像站,若留空则为默认的 www.gravatar.com
gravatarSite = ""
# Gravatar 邮箱,用于优先在主页显示的头像
gravatarEmail = ""
# 主页显示头像的 URL
Expand Down
7 changes: 5 additions & 2 deletions layouts/partials/home/profile.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{- $profile := .Site.Params.home.profile -}}
<div class="home-profile">
{{- $avatar := $profile.avatarURL -}}
{{- with $profile.gravatarEmail -}}
{{- $avatar = md5 . | printf "https://www.gravatar.com/avatar/%v?s=240&d=mp" -}}
{{- if $profile.gravatarEmail -}}
{{- with $profile -}}
{{- $site := .gravatarSite | default "www.gravatar.com" -}}
{{- $avatar = md5 .gravatarEmail | printf "https://%v/avatar/%v?s=240&d=mp" $site -}}
{{- end -}}
{{- end -}}
{{- if $avatar -}}
<div class="home-avatar">
Expand Down
2 changes: 1 addition & 1 deletion static/service-worker.min.js.map

Large diffs are not rendered by default.