/* * This is used to wrap MDX as returned from the mdxLoader * method (see shared/mdx/loader.js) * It is NOT for wrapping plain markdown/mdx */ import { useState, useEffect, Fragment } from 'react' // See: https://mdxjs.com/guides/mdx-on-demand/ import { run } from '@mdx-js/mdx' import * as runtime from 'react/jsx-runtime.js' // Components that are available in all MDX import { list as designs } from '@freesewing/pattern-info' import Popout from '../popout' import Highlight from '../mdx/highlight' import YouTube from '../mdx/youtube' //import * as dfltComponents from 'shared/components/elements/in-mdx' const DesignIterator = props => { const Component = props.component return designs.map(design => ) } const Figure = props => (
{props?.alt
{props.title || 'FIXME: No title property set on this image'}
) const Example = props =>

FIXME: Example still todo

const MdxWrapper = ({mdx, components={}}) => { const [mdxModule, setMdxModule] = useState() useEffect(() => { ;(async () => { setMdxModule(await run(mdx, runtime)) })() }, [mdx]) const dfltComponents = { Example, Fixme: props => , Note: props => , Tip: props => , Related: props => , Link: props => , Warning: props => , YouTube, // Tailwind typography plugin overrides h5: props =>
{props.children}
, h6: props =>
{props.children}
, pre: props => , //code: props => , DesignIterator, } /* * We use some default components that are available * everywhere in MDX, but we also accept passing in * extra components via props */ const allComponents = { ...dfltComponents, ...components } // React component for MDX content const MdxContent = mdxModule ? mdxModule.default : Fragment return (
) } export default MdxWrapper