Merge pull request #3141 from aplgr/fix/sharing-links-url-encoding

🐛 Fix special characters in social sharing links
This commit is contained in:
Nuno C. authored and GitHub committed 2026-11-11 18:26:50 +00:00
commit b917f81216
2 files changed
+6 -2

No files matched your search

+1 -1
View File
@@ -52,6 +52,6 @@
"mastodon": {
"icon": "mastodon",
"title": "sharing.mastodon",
"url": "https://share.joinmastodon.org/#text=%[2]s %[1]s"
"url": "https://share.joinmastodon.org/#text=%[2]s%%20%[1]s"
}
}
+5 -1
View File
@@ -1,12 +1,16 @@
{{ with .Params.sharingLinks | default (.Site.Params.article.sharingLinks | default false) }}
{{ $links := hugo.Data.sharing }}
{{ $pageURL := urlquery $.Permalink }}
{{ $pageTitle := urlquery $.Title }}
{{ $mastodonURL := replace $pageURL "+" "%20" }}
{{ $mastodonTitle := replace $pageTitle "+" "%20" }}
<section class="flex flex-row flex-wrap justify-center pt-4 text-xl">
{{ range . }}
{{ with index $links . }}
<a
class="m-1 rounded bg-neutral-300 p-1.5 text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800"
target="_blank"
href="{{ printf .url $.Permalink $.Title | safeURL }}"
href="{{ if eq .icon "mastodon" }}{{ printf .url $mastodonURL $mastodonTitle | safeURL }}{{ else }}{{ printf .url $pageURL $pageTitle | safeURL }}{{ end }}"
title="{{ i18n .title }}"
aria-label="{{ i18n .title }}">
{{ partial "icon.html" .icon }}