import React from 'react'; import PropTypes from 'prop-types'; import { DevidedPagePath } from '@growi/core'; export const PagePathLabel = (props) => { const dPagePath = new DevidedPagePath(props.page.path, false, true); let classNames = ['']; classNames = classNames.concat(props.additionalClassNames); if (props.isLatterOnly) { return {dPagePath.latter}; } if (props.isFormerOnly) { const textElem = dPagePath.isFormerRoot ? <>/ : <>{dPagePath.former}; return {textElem}; } const textElem = dPagePath.isRoot ? <>/ : <>{dPagePath.former}/{dPagePath.latter}; return {textElem}; }; PagePathLabel.propTypes = { page: PropTypes.object.isRequired, isLatterOnly: PropTypes.bool, isFormerOnly: PropTypes.bool, additionalClassNames: PropTypes.arrayOf(PropTypes.string), }; PagePathLabel.defaultProps = { additionalClassNames: [], };