mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
feat: implement Gravatar functionality and refactor avatar handling in profile
This commit is contained in:
@@ -661,7 +661,7 @@ orderby = "name" # Order of tags, optional values: ["name", "count"]
|
||||
enable = false
|
||||
# Gravatar Email for preferred avatar in home page
|
||||
gravatarEmail = ""
|
||||
# URL of avatar shown in home page
|
||||
# URL of avatar shown in home page, default is author's avatar
|
||||
avatarURL = ""
|
||||
# FixIt 0.2.17 | NEW identifier of avatar menu link
|
||||
avatarMenu = ""
|
||||
|
||||
@@ -28,17 +28,9 @@
|
||||
{{- with $authorParam.avatar -}}{{ $author = dict "avatar" . | merge $author }}{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $gravatar := site.Params.gravatar -}}
|
||||
{{- if $gravatar.enable | and $author.email -}}
|
||||
{{- with $gravatar -}}
|
||||
{{- /* TODO migrate to 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 -}}
|
||||
{{- $gravatar := dict "Email" $author.email "Size" "32" | partial "function/get-gravatar.html" -}}
|
||||
{{- with $gravatar -}}
|
||||
{{- $author = dict "avatar" . | merge $author -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $author -}}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{{- /*
|
||||
Get Gravatar URL.
|
||||
@param {String} Email the email address
|
||||
@param {String} Size the size in pixels (optional, default: 200)
|
||||
@returns {String} the Gravatar URL
|
||||
@example {{- $gravatar := dict "Email" "user@example.com" "Size" "32" | partial "function/get-gravatar.html" -}}
|
||||
*/ -}}
|
||||
|
||||
{{- $config := site.Params.gravatar -}}
|
||||
{{- $gravatar := "" -}}
|
||||
{{- if $config.enable | and .Email -}}
|
||||
{{- with $config -}}
|
||||
{{- $gravatar =
|
||||
printf "https://%v/avatar/%v?s=%v&d=%v"
|
||||
(path.Clean ($.Host | default .Host) | default "www.gravatar.com")
|
||||
(md5 $.Email)
|
||||
($.Size | default 200)
|
||||
(.Style | default "")
|
||||
-}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $gravatar -}}
|
||||
@@ -1,16 +1,8 @@
|
||||
{{- $profile := .Site.Params.home.profile -}}
|
||||
{{- $author := partial "function/get-author-map.html" .Params.author -}}
|
||||
|
||||
<div class="home-profile">
|
||||
{{- $avatar := $profile.avatarURL -}}
|
||||
{{- $gravatar := .Site.Params.gravatar -}}
|
||||
{{- if $gravatar.enable | and $profile.gravatarEmail -}}
|
||||
{{- with $gravatar -}}
|
||||
{{- $avatar = printf "https://%v/avatar/%v?s=240&d=%v"
|
||||
(path.Clean .Host | default "www.gravatar.com")
|
||||
(md5 $profile.gravatarEmail)
|
||||
(.Style | default "mp")
|
||||
-}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $avatar := dict "Email" $profile.gravatarEmail "Size" "96" | partial "function/get-gravatar.html" | default $profile.avatarURL | default $author.avatar -}}
|
||||
{{- if $avatar -}}
|
||||
<div class="home-avatar">
|
||||
{{- $menus := $.Site.Menus.main | default slice -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- hugo.Store.Set "version" "v0.4.0-alpha.3-20251221161325-3f145760" -}}
|
||||
{{- hugo.Store.Set "version" "v0.4.0-alpha.3-20251222033541-3c7babb5" -}}
|
||||
{{- .Store.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
Reference in New Issue
Block a user