PageTitle.tsx 806 B

123456789101112131415161718192021222324252627282930
  1. import { FC, useState } from 'react';
  2. import nodePath from 'path';
  3. import type { IPagePopulatedToShowRevision } from '@growi/core';
  4. import { TextInputForPageTitleAndPath } from './TextInputForPageTitleAndPath';
  5. type Props = {
  6. currentPagePath: string,
  7. currentPage: IPagePopulatedToShowRevision;
  8. }
  9. export const PageTitle: FC<Props> = (props) => {
  10. const { currentPagePath, currentPage } = props;
  11. const [isRenameInputShown, setRenameInputShown] = useState(false);
  12. const pageName = nodePath.basename(currentPagePath ?? '') || '/';
  13. const stateHandler = { isRenameInputShown, setRenameInputShown };
  14. return (
  15. <TextInputForPageTitleAndPath
  16. currentPagePath={currentPagePath}
  17. currentPage={currentPage}
  18. stateHandler={stateHandler}
  19. inputValue={pageName}
  20. />
  21. );
  22. };