From 86d264113d4195c5cd11dec0f58891bcd487ec48 Mon Sep 17 00:00:00 2001
From: canghai118 <3394863+canghai118@users.noreply.github.com>
Date: Thu, 21 May 2026 09:43:00 +0800
Subject: [PATCH 1/3] feat(post): share request button copies canonical URL via
toast
Use vue-sonner for feedback and move global Toaster to top-center.
Share URL is built from the post slug so it stays correct when the
post is opened in a modal over a different page.
---
app/app.vue | 2 +-
app/components/post/PostDetail.vue | 14 +++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/app/app.vue b/app/app.vue
index 898cc04..0efe9cc 100644
--- a/app/app.vue
+++ b/app/app.vue
@@ -9,5 +9,5 @@ import 'vue-sonner/style.css'
-
+
diff --git a/app/components/post/PostDetail.vue b/app/components/post/PostDetail.vue
index 00884ec..10ad59e 100644
--- a/app/components/post/PostDetail.vue
+++ b/app/components/post/PostDetail.vue
@@ -2,6 +2,7 @@
import { MdEditor } from 'md-editor-v3'
import 'md-editor-v3/lib/style.css'
import '~/assets/css/md-editor-preview.css'
+import { toast } from 'vue-sonner'
import { sanitizeAttachmentHtml } from '~/utils/attachment';
@@ -280,6 +281,17 @@ async function handleDeleteComment(commentId: string) {
watch(commentSort, () => {
store.fetchComments(props.slug, commentSort.value)
})
+
+async function handleShare() {
+ // Canonical post URL — independent of current location (post may be opened in a modal)
+ const url = `${window.location.origin}/p/${props.slug}`
+ try {
+ await navigator.clipboard.writeText(url)
+ toast.success('Link copied to clipboard')
+ } catch {
+ toast.error('Failed to copy link')
+ }
+}
@@ -475,7 +487,7 @@ watch(commentSort, () => {