From 02919a7d4866b3f68722363277f250db7e5a7bdd Mon Sep 17 00:00:00 2001
From: Dillon <dillonzq@outlook.com>
Date: Wed, 19 Feb 2020 18:55:40 +0800
Subject: [PATCH] fix(social): fix social link bug (#81)

---
 exampleSite/config.toml                  | 6 +++---
 layouts/partials/function/icon-link.html | 2 +-
 layouts/partials/home/social.html        | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 00183203..fdce7583 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -212,12 +212,12 @@ dateFormatToUse = "2006-01-02"
     # Vine = "xxxx"
     # Googlescholar = "xxxx"
     # Researchgate = "xxxx"
-    # Mastodon = "xxxx"
-    # MastodonPrefix = "https://mastodon.technology/"
+    # Mastodon = "@xxxx"
+    # MastodonPrefix = "https://mastodon.technology"
     # Thingiverse = "xxxx"
     # Devto = "xxxx"
     # Gitea = "xxxx"
-    # XMPP = "xxxx"
+    # XMPP = "xxxx@example.com"
     # Matrix = "xxxx"
     # Bilibili = "xxxx"
 
diff --git a/layouts/partials/function/icon-link.html b/layouts/partials/function/icon-link.html
index 13dd55c3..0593855b 100644
--- a/layouts/partials/function/icon-link.html
+++ b/layouts/partials/function/icon-link.html
@@ -1,3 +1,3 @@
-<a href="{{ index . `href` }}" rel="me noopener noreffer" target="_blank" title="{{ index . `title` }}">
+<a href="{{ index . `href` | safeURL }}" rel="me noopener noreffer" target="_blank" title="{{ index . `title` }}">
     {{- partial "function/icon.html" . -}}
 </a>
diff --git a/layouts/partials/home/social.html b/layouts/partials/home/social.html
index f4e85827..8644ad18 100644
--- a/layouts/partials/home/social.html
+++ b/layouts/partials/home/social.html
@@ -378,8 +378,8 @@
 
 {{- /* 055: Mastodon */ -}}
 {{- with .Site.Params.Social.Mastodon -}}
-    {{- $MastodonPrefix := $.Site.Params.Social.MastodonPrefix | default "https://mastodon.social/" -}}
-    {{- $options := dict "href" $MastodonPrefix "title" "Mastodon" -}}
+    {{- $MastodonPrefix := $.Site.Params.Social.MastodonPrefix | default "https://mastodon.social" -}}
+    {{- $options := dict "href" (printf "%s/%s" $MastodonPrefix .) "title" "Mastodon" -}}
     {{- $options = dict "class" "fab fa-mastodon fa-fw" | merge $options -}}
     {{- partial "function/icon-link.html" $options -}}
 {{- end -}}