MarpSlides.tsx 717 B

1234567891011121314151617181920212223242526272829
  1. import Head from 'next/head';
  2. import { presentationMarpit, slideMarpit } from '../services/growi-marpit';
  3. type Props = {
  4. children?: string,
  5. presentation?: boolean,
  6. }
  7. export const MarpSlides = (props: Props): JSX.Element => {
  8. const { children, presentation } = props;
  9. const marpit = presentation ? presentationMarpit : slideMarpit;
  10. const { html, css } = marpit.render(children ?? '');
  11. return (
  12. <>
  13. <Head>
  14. <style>{css}</style>
  15. </Head>
  16. <div
  17. // eslint-disable-next-line react/no-danger
  18. dangerouslySetInnerHTML={{
  19. // DOMpurify.sanitize delete elements in <svg> so sanitize is not used here.
  20. __html: html,
  21. }}
  22. />
  23. </>
  24. );
  25. };