diff --git a/src/components/Posts/PostDetailModal.jsx b/src/components/Posts/PostDetailModal.jsx index eba7fa1..e99e523 100644 --- a/src/components/Posts/PostDetailModal.jsx +++ b/src/components/Posts/PostDetailModal.jsx @@ -695,8 +695,20 @@ export default function PostDetailModal({ post, onClose, onPostUpdated, onPostDe }, [postId, liked, post?.guid, post?.app_id]); const handleShare = useCallback(async () => { - if (!postId) return; - const shareUrl = `${window.location.origin}/p/${postId}`; + if (!postId && !post?.guid) return; + let shareUrl; + if (post?.app_id && post?.guid) { + // SEO-friendly URL: /news/slug-shortguid + const slug = (post?.title || "post") + .toLowerCase() + .replace(/[^a-z0-9]+/g, "-") + .replace(/^-+|-+$/g, "") + .slice(0, 50); + const shortGuid = post.guid.slice(0, 8); + shareUrl = `${window.location.origin}/news/${slug}-${shortGuid}`; + } else { + shareUrl = `${window.location.origin}/p/${postId}`; + } if (navigator.share) { try { await navigator.share({ title: post?.title, url: shareUrl }); } catch {} } else { navigator.clipboard?.writeText(shareUrl); } const res = await recordPostShare(postId, post?.guid, post?.app_id);