PageContentFooter.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from 'react';
  2. import type { IPage, IUser } from '@growi/core';
  3. import dynamic from 'next/dynamic';
  4. import { useSWRxCurrentPage } from '~/stores/page';
  5. import type { AuthorInfoProps } from './Navbar/AuthorInfo';
  6. import { Skelton } from './Skelton';
  7. import styles from './PageContentFooter.module.scss';
  8. const AuthorInfo = dynamic<AuthorInfoProps>(() => import('./Navbar/AuthorInfo').then(mod => mod.AuthorInfo), {
  9. ssr: false,
  10. loading: () => <Skelton additionalClass={`${styles['page-content-footer-skelton']} mb-3`} />,
  11. });
  12. export type PageContentFooterProps = {
  13. page: IPage,
  14. }
  15. export const PageContentFooter = (props: PageContentFooterProps): JSX.Element => {
  16. const { page } = props;
  17. const {
  18. creator, lastUpdateUser, createdAt, updatedAt,
  19. } = page;
  20. return (
  21. <div className={`${styles['page-content-footer']} page-content-footer py-4 d-edit-none d-print-none}`}>
  22. <div className="grw-container-convertible">
  23. <div className="page-meta">
  24. <AuthorInfo user={creator as IUser} date={createdAt} mode="create" locate="footer" />
  25. <AuthorInfo user={lastUpdateUser as IUser} date={updatedAt} mode="update" locate="footer" />
  26. </div>
  27. </div>
  28. </div>
  29. );
  30. };
  31. export const CurrentPageContentFooter = (): JSX.Element => {
  32. const { data: currentPage } = useSWRxCurrentPage();
  33. if (currentPage == null) {
  34. return <></>;
  35. }
  36. return <PageContentFooter page={currentPage} />;
  37. };