summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2025-12-18 01:02:55 +0800
committerBigCoke233 <hi@guhub.cn>2025-12-18 01:02:55 +0800
commit24d94d68bd17848f9ee259cdd99ab61a40d342f2 (patch)
treeaceb9dd05a703694b33a3222991468fbea46ad8f
parent0b40d6b53bebe636c3c2e891497c3d2d9bd53dcb (diff)
fix: webmention count is always zero if url contains Chinese
call encodeURICompoent() before passing permalink to API Former-commit-id: 5737430d93fd51cdeabca788b4172bc981fc195b
-rw-r--r--layouts/_partials/posts/action-menu/webmention-button.html5
1 files changed, 3 insertions, 2 deletions
diff --git a/layouts/_partials/posts/action-menu/webmention-button.html b/layouts/_partials/posts/action-menu/webmention-button.html
index e0940d9a..190b0f8b 100644
--- a/layouts/_partials/posts/action-menu/webmention-button.html
+++ b/layouts/_partials/posts/action-menu/webmention-button.html
@@ -1,4 +1,4 @@
-{{ partial "components/toggle-button.html" (dict
+{{ partial "components/toggle-button.html" (dict
"id" "webmention"
"title" (T "actionMenu.webmention")
"icon" "/img/mention.svg"
@@ -7,8 +7,9 @@
) }}
<script>
+const target = encodeURIComponent("{{ .Permalink }}")
document.addEventListener('DOMContentLoaded', () => {
- fetch("https://webmention.io/api/count?target={{ .Permalink }}")
+ fetch("https://webmention.io/api/count?target="+target)
.then(response => response.json())
.then(responseJson => {
document.getElementById("mention-count").textContent = responseJson.count;