PageAuthorInfo.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { memo } from 'react';
  2. import { pagePathUtils } from '@growi/core/dist/utils';
  3. import { useCurrentPathname } from '~/stores-universal/context';
  4. import { useSWRxCurrentPage } from '~/stores/page';
  5. import { useIsAbleToShowPageAuthors } from '~/stores/ui';
  6. import { AuthorInfo } from '../AuthorInfo';
  7. import styles from './PageAuthorInfo.module.scss';
  8. export const PageAuthorInfo = memo((): JSX.Element => {
  9. const { data: currentPage } = useSWRxCurrentPage();
  10. const { data: currentPathname } = useCurrentPathname();
  11. const { data: isAbleToShowPageAuthors } = useIsAbleToShowPageAuthors();
  12. if (!isAbleToShowPageAuthors) {
  13. return <></>;
  14. }
  15. const path = currentPage?.path ?? currentPathname;
  16. if (pagePathUtils.isUsersHomepage(path ?? '')) {
  17. return <></>;
  18. }
  19. return (
  20. <ul className={`grw-page-author-info ${styles['grw-page-author-info']} text-nowrap border-start d-none d-lg-block d-edit-none py-2 ps-4 mb-0 ms-3`}>
  21. <li className="pb-1">
  22. {currentPage != null && (
  23. <AuthorInfo user={currentPage.creator} date={currentPage.createdAt} mode="create" locate="subnav" />
  24. )}
  25. </li>
  26. <li className="mt-1 pt-1 border-top">
  27. {currentPage != null && (
  28. <AuthorInfo user={currentPage.lastUpdateUser} date={currentPage.updatedAt} mode="update" locate="subnav" />
  29. )}
  30. </li>
  31. </ul>
  32. );
  33. });