From: Danilo M. Date: Sun, 5 Apr 2026 07:19:48 +0000 (+0200) Subject: feat: add gravatar shortcode template X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=627b110437ccd089bc3d9a5160ec41569f114e82;p=danix2-hugo-theme.git feat: add gravatar shortcode template Ported gravatar shortcode from previous theme. Allows embedding Gravatar images with customizable size, link, and caption. Usage: {{}} Co-Authored-By: Claude Haiku 4.5 --- diff --git a/layouts/shortcodes/gravatar.html b/layouts/shortcodes/gravatar.html new file mode 100644 index 0000000..56e2514 --- /dev/null +++ b/layouts/shortcodes/gravatar.html @@ -0,0 +1,52 @@ +{{/* + * The gravatar shortcode: + * All arguments are optional, main ones are mail and size and have a fallback set in place. + * Args: + * mail: [string] The email address. Falls back to .Site.Params.author_email which should be set in your config file. + * size: [int] The size of the fetched image. Defaults to 200 if not set. + * class: [string] The class to give to the figure block. + * link: [string] The address to link the picture to. + * target: [string] Where to open the link. One of "_blank", "_self", "_parent", "_top". + * caption: [string] Caption text to show with the image. Supports Markdown. + * + * Usage: + * {{< gravatar mail="some@address.com" size=150 class="some class" link="https://example.com" target="_blank" rel="author" caption="Here's a picture of a dog." >}} + * + * Output: + *
+ * + *
+ *

+ * Here's a picture of a dog. + *

+ *
+ *
+ * + */}} + +{{- $mailhash := $.Site.Params.author_email -}} +{{- if .Get "mail" -}}{{- $mailhash = .Get "mail" -}}{{- end -}} +{{- $hash := $mailhash | lower | md5 -}} + + +{{- if .Get "link" -}} + +{{- end }} + {{ with .Get +{{- if .Get "link" -}} + +{{- end }} +{{- if .Get "caption" -}} +
+

+ {{- .Get "caption" | markdownify -}} +

+
+{{- end }} +