From 31731c9996a1e08109fd1171ee09663fd770d35a Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Fri, 18 Sep 2026 14:31:23 -0500 Subject: [PATCH] js: Fix copy to clipboard button stuck as "Copied" when clicked twice --- assets/js/{bobatheme.js => bobatheme.tmpl.js} | 3 +-- layouts/_partials/head.html | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) rename assets/js/{bobatheme.js => bobatheme.tmpl.js} (90%) diff --git a/assets/js/bobatheme.js b/assets/js/bobatheme.tmpl.js similarity index 90% rename from assets/js/bobatheme.js rename to assets/js/bobatheme.tmpl.js index 3e4f7fe..a12a5ee 100644 --- a/assets/js/bobatheme.js +++ b/assets/js/bobatheme.tmpl.js @@ -14,9 +14,8 @@ async function copy_to_clipboard(button) { await navigator.clipboard.writeText(rawCode); // TODO: maybe we could add a fancier indicator, like a flash or something - const originalCopyText = button.innerHTML; button.innerHTML = "Copied!"; setTimeout(() => { - button.innerHTML = originalCopyText; + button.innerHTML = "{{ i18n "copy_to_clipboard" }}"; }, 3000); } diff --git a/layouts/_partials/head.html b/layouts/_partials/head.html index 747c8f2..c0d1afe 100644 --- a/layouts/_partials/head.html +++ b/layouts/_partials/head.html @@ -19,8 +19,10 @@ {{ end }} - {{ with resources.Get "js/bobatheme.js" | fingerprint "sha512" }} - + {{ with resources.Get "js/bobatheme.tmpl.js" }} + {{ with resources.ExecuteAsTemplate "js/bobatheme.js" $ . | fingerprint "sha512" }} + + {{ end }} {{ end }} {{ if not hugo.IsServer }}