CustomSidebarSubstance.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import React, { type JSX } from 'react';
  2. import RevisionRenderer from '~/components/PageView/RevisionRenderer';
  3. import { useSWRxPageByPath } from '~/stores/page';
  4. import { useCustomSidebarOptions } from '~/stores/renderer';
  5. import loggerFactory from '~/utils/logger';
  6. import { SidebarNotFound } from './CustomSidebarNotFound';
  7. import styles from './CustomSidebarSubstance.module.scss';
  8. const logger = loggerFactory('growi:components:CustomSidebarSubstance');
  9. export const CustomSidebarSubstance = (): JSX.Element => {
  10. const { data: rendererOptions } = useCustomSidebarOptions({ suspense: true });
  11. const { data: page } = useSWRxPageByPath('/Sidebar', { suspense: true });
  12. if (rendererOptions == null) return <></>;
  13. const markdown = page?.revision?.body;
  14. return (
  15. <div
  16. className={`py-4 grw-custom-sidebar-content ${styles['grw-custom-sidebar-content']}`}
  17. >
  18. {markdown == null ? (
  19. <SidebarNotFound />
  20. ) : (
  21. <RevisionRenderer
  22. rendererOptions={rendererOptions}
  23. markdown={markdown}
  24. />
  25. )}
  26. </div>
  27. );
  28. };