diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-15 15:52:12 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-15 15:52:12 +0200 |
| commit | 798970f43e522e4b54207a79bf52dee8710d84dc (patch) | |
| tree | 0d4b4b6c04e2b62e0704160687ed1a807e8f1db2 /themes | |
| parent | 7cbc34a2a583e2a909428d25342f255960a90fb3 (diff) | |
| download | danixxyz-798970f43e522e4b54207a79bf52dee8710d84dc.tar.gz danixxyz-798970f43e522e4b54207a79bf52dee8710d84dc.zip | |
feat: create gravatar shortcode with MD5 hashing
Diffstat (limited to 'themes')
| -rw-r--r-- | themes/danix-xyz-hacker/shortcodes/gravatar.html | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/themes/danix-xyz-hacker/shortcodes/gravatar.html b/themes/danix-xyz-hacker/shortcodes/gravatar.html new file mode 100644 index 0000000..7151ee5 --- /dev/null +++ b/themes/danix-xyz-hacker/shortcodes/gravatar.html @@ -0,0 +1,17 @@ +{{- $email := .Get "email" -}} +{{- $size := .Get "size" | default "256" -}} +{{- $alt := .Get "alt" | default "User avatar" -}} +{{- $class := .Get "class" | default "w-32 h-32 rounded-full" -}} + +{{- if $email -}} + {{- $hash := md5 (trim (strings.ToLower $email)) -}} + {{- $gravatarURL := printf "https://www.gravatar.com/avatar/%s?s=%s&d=identicon" $hash $size -}} + <img + src="{{ $gravatarURL }}" + alt="{{ $alt }}" + class="{{ $class }}" + loading="lazy" + /> +{{- else -}} + {{- errorf "gravatar shortcode: 'email' parameter is required" -}} +{{- end -}} |
