import React, { FC } from 'react'; import { DevidedPagePath } from '@growi/core'; type TextElemProps = { children?: React.ReactNode isHTML?: boolean, } const TextElement: FC = (props: TextElemProps) => ( <> { props.isHTML // eslint-disable-next-line react/no-danger ? : <>{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; if (isLatterOnly) { textElem = {dPagePath.latter}; } else if (isFormerOnly) { textElem = dPagePath.isFormerRoot ? <>/ : {dPagePath.former}; } else { textElem = dPagePath.isRoot ? / : {dPagePath.former}/{dPagePath.latter}; } return {textElem}; };