diff --git a/src/components/pages/PreviewAddressPage.tsx b/src/components/pages/PreviewAddressPage.tsx index 388e76c..3eaa108 100644 --- a/src/components/pages/PreviewAddressPage.tsx +++ b/src/components/pages/PreviewAddressPage.tsx @@ -7,16 +7,16 @@ import { toast } from "sonner"; /** * PreviewAddressPage - Preview or redirect naddr identifiers - * Route: /naddr... + * Route: /naddr1* * For spellbooks (kind 30777), redirects to /:actor/:identifier * For all other addressable events, shows detail view */ export default function PreviewAddressPage() { - const { identifier } = useParams<{ identifier: string }>(); + const params = useParams<{ "*": string }>(); const navigate = useNavigate(); - // Reconstruct the full identifier - const fullIdentifier = identifier ? `naddr${identifier}` : undefined; + // Get the full naddr from the URL (naddr1 + captured part) + const fullIdentifier = params["*"] ? `naddr1${params["*"]}` : undefined; // Decode the naddr identifier (synchronous, memoized) const { decoded, error } = useNip19Decode(fullIdentifier, "naddr"); diff --git a/src/components/pages/PreviewEventPage.tsx b/src/components/pages/PreviewEventPage.tsx index 101ebbc..d792319 100644 --- a/src/components/pages/PreviewEventPage.tsx +++ b/src/components/pages/PreviewEventPage.tsx @@ -7,26 +7,27 @@ import { toast } from "sonner"; /** * PreviewEventPage - Preview a Nostr event from a nevent or note identifier - * Routes: /nevent..., /note... + * Routes: /nevent1*, /note1* * This page shows a single event view without affecting user's workspace layout */ export default function PreviewEventPage() { - const { identifier } = useParams<{ identifier: string }>(); + const params = useParams<{ "*": string }>(); const navigate = useNavigate(); const location = useLocation(); - // Determine the prefix based on the current path + // Determine the prefix based on the current path and reconstruct full identifier const fullIdentifier = useMemo(() => { - if (!identifier) return undefined; + const captured = params["*"]; + if (!captured) return undefined; const path = location.pathname; - if (path.startsWith("/nevent")) { - return `nevent${identifier}`; - } else if (path.startsWith("/note")) { - return `note${identifier}`; + if (path.startsWith("/nevent1")) { + return `nevent1${captured}`; + } else if (path.startsWith("/note1")) { + return `note1${captured}`; } return undefined; - }, [identifier, location.pathname]); + }, [params, location.pathname]); // Decode the event identifier (synchronous, memoized) const { decoded, error } = useNip19Decode(fullIdentifier); diff --git a/src/components/pages/PreviewProfilePage.tsx b/src/components/pages/PreviewProfilePage.tsx index 1668359..8b2a207 100644 --- a/src/components/pages/PreviewProfilePage.tsx +++ b/src/components/pages/PreviewProfilePage.tsx @@ -6,15 +6,15 @@ import { toast } from "sonner"; /** * PreviewProfilePage - Preview a Nostr profile from an npub identifier - * Route: /npub... + * Route: /npub1* * This page shows a single profile view without affecting user's workspace layout */ export default function PreviewProfilePage() { - const { identifier } = useParams<{ identifier: string }>(); + const params = useParams<{ "*": string }>(); const navigate = useNavigate(); - // Reconstruct the full identifier (react-router splits on /) - const fullIdentifier = identifier ? `npub${identifier}` : undefined; + // Get the full npub from the URL (npub1 + captured part) + const fullIdentifier = params["*"] ? `npub1${params["*"]}` : undefined; // Decode the npub identifier (synchronous, memoized) const { decoded, error } = useNip19Decode(fullIdentifier, "npub"); diff --git a/src/root.tsx b/src/root.tsx index 3cb5929..2833f3a 100644 --- a/src/root.tsx +++ b/src/root.tsx @@ -16,7 +16,7 @@ const router = createBrowserRouter([ ), }, { - path: "/npub:identifier", + path: "/npub1*", element: ( @@ -24,7 +24,7 @@ const router = createBrowserRouter([ ), }, { - path: "/nevent:identifier", + path: "/nevent1*", element: ( @@ -32,7 +32,7 @@ const router = createBrowserRouter([ ), }, { - path: "/note:identifier", + path: "/note1*", element: ( @@ -40,7 +40,7 @@ const router = createBrowserRouter([ ), }, { - path: "/naddr:identifier", + path: "/naddr1*", element: (