CustomSidebarSubstance.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import RevisionRenderer from '~/components/Page/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 className={`py-3 grw-custom-sidebar-content ${styles['grw-custom-sidebar-content']}`}>
  16. { markdown == null
  17. ? <SidebarNotFound />
  18. : (
  19. <RevisionRenderer
  20. rendererOptions={rendererOptions}
  21. markdown={markdown}
  22. />
  23. )
  24. }
  25. </div>
  26. );
  27. };