Jeremy Mayeres e64f74c492
theme(fix): social follow/share using new config (#821)
A recent commit changed the config for social to use a map instead of a
list, this broke the social share/follow, though a quick fix seems to
restore it and removes the need for sorting.

Closes #808

I checked the wikipedia example from the original issue and it seems
like this will also fix that. I'm not sure if you had anything else to
fix, feel free to push to my branch.
2025-02-09 15:03:52 +07:00

57 lines
2.1 KiB
HTML

{{- $context := . -}}
{{- $disabled := $context.Params.disable_share | default "false" -}}
{{- $config := site.Params.ananke.social -}}
{{- with $config.share.disable_share -}}
{{- $disabled := . -}}
{{- end -}}
{{- if eq "false" $disabled -}}
{{- $title := $context.Title -}}
{{- $url := printf "%s" $context.Permalink | absLangURL -}}
{{- $networks := $config.share.networks -}}
{{- $hasLabel := $config.share.sharetext | default "true" -}}
{{- $hasIcon := $config.share.icons | default "true" -}}
<div id="sharing" class="mt3 ananke-socials">
{{- range $networks -}}
{{- $network := . -}}
{{- $setup := index $config.networks $network -}}
{{/* @todo i18n $sharetext := lang.Translate (fmt.Printf "share_on_%s" $setup.slug) */}}
{{- $label := "" -}}
{{ with $config.share.sharetext -}}
{{- $label = printf "Share on %s" $setup.label -}}
{{- end -}}
{{ if eq $setup.share "false" | default "true" -}}
{{- continue -}}
{{/* @todo notification into CLI that a network is configured but not supported */}}
{{- end -}}
{{- $options := (dict "context" page "setup" $setup) }}
{{- $href := partial "func/social/getShareLink.html" $options -}}
<a href="{{ $href }}"
class="ananke-social-link {{ $setup.slug }} no-underline"
title="{{ $label }}" aria-label="{{ $label }}"
target="_blank" rel="nofollow noopener noreferrer">
{{ with $config.share.icons -}}
{{/* @todo add the following lines to a partial, reused in social/follow.html */}}
{{- with $setup.icon -}}
{{- $icon := resources.Get (printf "ananke/socials/%s.svg" .) -}}
{{- with $icon -}}
<span class="icon">
{{ .Content | safeHTML }}
{{/* @todo indicator for missing or misconfigured icon */}}
</span>
{{- end -}}
{{- else -}}
{{- $label -}}
{{- end -}}
{{- else -}}
{{- $label -}}
{{- end -}}
</a>
{{- end -}}
</div>
{{- end -}} {{/* if eq "true" $disabled */}}