import React, { FC } from 'react'; import { DevidedPagePath } from '@growi/core/dist/models'; import { pagePathUtils } from '@growi/core/dist/utils'; import dynamic from 'next/dynamic'; import { useIsNotFound } from '~/stores/page'; import LinkedPagePath from '../../../models/linked-page-path'; import { PagePathHierarchicalLink } from '../PagePathHierarchicalLink'; const { isTrashPage } = pagePathUtils; type Props = { pagePath: string, pageId?: string | null, isSingleLineMode?: boolean, isCollapseParents?: boolean, } const CopyDropdown = dynamic(() => import('../CopyDropdown').then(mod => mod.CopyDropdown), { ssr: false }); export const PagePathNav: FC = (props: Props) => { const { pageId, pagePath, isSingleLineMode, isCollapseParents, } = props; const dPagePath = new DevidedPagePath(pagePath, false, true); const { data: isNotFound } = useIsNotFound(); const isInTrash = isTrashPage(pagePath); let formerLink; let latterLink; // one line if (dPagePath.isRoot || dPagePath.isFormerRoot || isSingleLineMode) { const linkedPagePath = new LinkedPagePath(pagePath); latterLink = ; } // two line else { const linkedPagePathFormer = new LinkedPagePath(dPagePath.former); const linkedPagePathLatter = new LinkedPagePath(dPagePath.latter); formerLink = ; latterLink = ; } const copyDropdownId = `copydropdown-${pageId}`; const copyDropdownToggleClassName = 'd-block btn-outline-secondary btn-copy border-0 text-muted p-2'; return (
{formerLink}

{latterLink}

{ pageId != null && !isNotFound && (
) }
); };