summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2026-01-31 11:26:27 +0800
committerBigCoke233 <hi@guhub.cn>2026-01-31 11:26:27 +0800
commit276f4ef417b81a6c48d09f6c19bc51e1bcb82597 (patch)
tree82a8e25e7b59e155e88d1fe808ad8fd027127bfc
parentd0a912c51ee71cf87ea3a785fa546cb6ef267c73 (diff)
refactor: open source if no instance url provided
-rw-r--r--layouts/_partials/posts/fediverse-form.html20
1 files changed, 4 insertions, 16 deletions
diff --git a/layouts/_partials/posts/fediverse-form.html b/layouts/_partials/posts/fediverse-form.html
index 6c4fce6a..6d545088 100644
--- a/layouts/_partials/posts/fediverse-form.html
+++ b/layouts/_partials/posts/fediverse-form.html
@@ -9,24 +9,12 @@
<script>
function openInFediverse() {
const instance = document.getElementById('fediverse-instance').value.trim();
- {{ with .Params.toot }}
- const tootUrl = '{{ . }}';
- {{ else }}
- const tootUrl = '';
- {{ end }}
+ const tootUrl = '{{ .Params.toot }}';
- if (!instance) {
- alert('Please enter your Fediverse instance URL');
- return;
+ let url = tootUrl
+ if (instance) {
+ url = 'https://' + instance + '/authorize_interaction?uri=' + encodeURIComponent(tootUrl);
}
-
- if (!tootUrl) {
- alert('No toot available for this post');
- return;
- }
-
- // Open the toot interaction page on the user's instance
- const url = 'https://' + instance + '/authorize_interaction?uri=' + encodeURIComponent(tootUrl);
window.open(url, '_blank');
}
</script>