import type { FC, ReactNode } from 'react'; import { DevidedPagePath } from '@growi/core/dist/models'; type TextElemProps = { children?: ReactNode; isHTML?: boolean; }; const TextElement: FC = (props: TextElemProps) => ( <> {props.isHTML ? ( ) : ( <>{props.children} )} ); type Props = { path: string; isLatterOnly?: boolean; isFormerOnly?: boolean; isPathIncludedHtml?: boolean; additionalClassNames?: string[]; }; export const PagePathLabel: FC = (props: Props) => { const { isLatterOnly, isFormerOnly, isPathIncludedHtml, additionalClassNames, path, } = props; const dPagePath = new DevidedPagePath(path, false, true); const classNames = additionalClassNames || []; let textElem: JSX.Element | undefined; if (isLatterOnly) { textElem = ( {dPagePath.latter} ); } else if (isFormerOnly) { textElem = dPagePath.isFormerRoot ? ( <>/ ) : ( {dPagePath.former} ); } else { textElem = dPagePath.isRoot ? ( / ) : ( {dPagePath.former}/{dPagePath.latter} ); } return {textElem}; };