import { type JSX, useMemo } from 'react'; import { DevidedPagePath } from '@growi/core/dist/models'; import { pagePathUtils } from '@growi/core/dist/utils'; import LinkedPagePath from '~/models/linked-page-path'; import { PagePathHierarchicalLink } from '../PagePathHierarchicalLink'; import type { PagePathNavLayoutProps } from './PagePathNavLayout'; import { PagePathNavLayout } from './PagePathNavLayout'; import styles from './PagePathNav.module.scss'; const { isTrashPage } = pagePathUtils; const Separator = ({ className }: { className?: string }): JSX.Element => { return ( / ); }; export const PagePathNav = (props: PagePathNavLayoutProps): JSX.Element => { const { pagePath } = props; const isInTrash = isTrashPage(pagePath); const formerLink = useMemo(() => { const dPagePath = new DevidedPagePath(pagePath, false, true); // one line if (dPagePath.isRoot || dPagePath.isFormerRoot) { return undefined; } // two line const linkedPagePathFormer = new LinkedPagePath(dPagePath.former); return ( <> ); }, [isInTrash, pagePath]); const latterLink = useMemo(() => { const dPagePath = new DevidedPagePath(pagePath, false, true); // one line if (dPagePath.isRoot || dPagePath.isFormerRoot) { const linkedPagePath = new LinkedPagePath(pagePath); return ( ); } // two line const linkedPagePathLatter = new LinkedPagePath(dPagePath.latter); return ( ); }, [isInTrash, pagePath]); return ( ); };