fix(backlinks): navigate via buildPageUrl so reference clicks work
handleNavigate hand-built /<space>/page/<slugId>, a route that does not exist (real route is /s/<space>/p/<slug-id>), so clicking any linked reference did nothing. Use the canonical buildPageUrl helper, same as the wikilink node. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a1f2ee9e0a
commit
5e0f5cf49e
1 changed files with 12 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ import {
|
|||
} from '@tabler/icons-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { buildPageUrl } from '@/features/page/page.utils.ts';
|
||||
import { useBacklinks } from '../queries/backlinks-query';
|
||||
import type { BacklinkEntry } from '../queries/backlinks-query';
|
||||
import classes from './linked-references-panel.module.css';
|
||||
|
|
@ -84,10 +85,17 @@ export function LinkedReferencesPanel({ pageId }: LinkedReferencesPanelProps) {
|
|||
|
||||
const handleNavigate = (entry: BacklinkEntry) => {
|
||||
if (entry.source.slugId) {
|
||||
// Navigate to the source page that links here.
|
||||
// The full path includes the space slug — fall back to page UUID if slugId only.
|
||||
const spacePart = entry.source.spaceSlug ? `/${entry.source.spaceSlug}` : '';
|
||||
navigate(`${spacePart}/page/${entry.source.slugId}`);
|
||||
// Use the canonical builder so links land on the real
|
||||
// /s/<space>/p/<slug-id> route (same helper the wikilink node uses).
|
||||
// The previous hand-built `/<space>/page/<slugId>` path matched no
|
||||
// route, so clicking a reference did nothing.
|
||||
navigate(
|
||||
buildPageUrl(
|
||||
entry.source.spaceSlug ?? undefined,
|
||||
entry.source.slugId,
|
||||
entry.source.title ?? undefined,
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue