From 6399bc3dd0731e51c768fef34131f546b3f9a47a Mon Sep 17 00:00:00 2001 From: BigCoke233 Date: Sat, 31 Jan 2026 12:14:13 +0800 Subject: refactor: bundle fediform.js Former-commit-id: 2a05c35369a70e5a3df0c08cc1a19ccd0bd02f64 --- assets/js/fediform.js | 16 ++++++++++++++++ layouts/_partials/posts/fediverse-form.html | 21 --------------------- layouts/_partials/scripts.html | 1 + 3 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 assets/js/fediform.js diff --git a/assets/js/fediform.js b/assets/js/fediform.js new file mode 100644 index 00000000..96339d41 --- /dev/null +++ b/assets/js/fediform.js @@ -0,0 +1,16 @@ +const instanceInput = document.getElementById('fediverse-instance') +const savedInstance = localStorage.getItem("geedeapro.fediInstance") +if (savedInstance) instanceInput.value = savedInstance + +function openInFediverse() { + const instance = instanceInput.value.trim(); + const tootUrl = '{{ .Params.toot }}'; + + let url = tootUrl + if (instance) { + url = 'https://' + instance + '/authorize_interaction?uri=' + encodeURIComponent(tootUrl); + // save instance url to localStorage + localStorage.setItem("geedeapro.fediInstance", instance) + } + window.open(url, '_blank'); +} diff --git a/layouts/_partials/posts/fediverse-form.html b/layouts/_partials/posts/fediverse-form.html index f9998d1d..1ddc09a0 100644 --- a/layouts/_partials/posts/fediverse-form.html +++ b/layouts/_partials/posts/fediverse-form.html @@ -1,28 +1,7 @@ {{ if .Params.toot }} -

{{ T "actionMenu.fediverse" }}

- - - {{ end }} diff --git a/layouts/_partials/scripts.html b/layouts/_partials/scripts.html index 2875f27d..c6f4391d 100644 --- a/layouts/_partials/scripts.html +++ b/layouts/_partials/scripts.html @@ -12,6 +12,7 @@ (resources.Get "js/toc.js") (resources.Get "js/inject-footnotes.js") (resources.Get "js/back2top.js") + (resources.Get "js/fediform.js") }} {{ $articleBundle := $articleJS | resources.Concat "js/article-bundle.js" | minify | fingerprint }} -- cgit v1.2.3