1
0
Fork 0
freesewing/sites/shared/components/mdx/index.mjs

77 lines
2.2 KiB
JavaScript
Raw Normal View History

2023-09-29 16:01:27 +02:00
// __SDEFILE__ - This file is a dependency for the stand-alone environment
import { Popout } from 'shared/components/popout/index.mjs'
import { Highlight } from './highlight.mjs'
import { YouTube } from './youtube.mjs'
2023-05-19 16:31:28 +02:00
//import { Figure } from './figure.mjs'
2023-05-15 20:00:45 +02:00
import { ReadMore } from './read-more.mjs'
import { Tab, Tabs } from '../tabs.mjs'
import { TabbedExample as Example } from './tabbed-example.mjs'
import { HttpMethod, HttpStatusCode } from './http.mjs'
import { ControlTip } from '../control/tip.mjs'
2023-06-17 12:09:07 +02:00
import { DocsTitle, DocsLink } from './docs-helpers.mjs'
// Extra components
import { DesignInfo } from 'shared/components/designs/info.mjs'
import { collection } from 'site/hooks/use-design.mjs'
export const components = (site = 'org', slug = []) => {
const base = {
Comment: (props) => <Popout {...props} comment />,
Fixme: (props) => <Popout {...props} fixme />,
Link: (props) => <Popout {...props} link />,
Note: (props) => <Popout {...props} note />,
ReadMore: (props) => <ReadMore {...props} site={site} />,
Related: (props) => <Popout {...props} related />,
2023-09-29 16:01:27 +02:00
Tab,
Tabs,
Tip: (props) => <Popout {...props} tip />,
2023-06-16 20:00:26 +02:00
Tldr: (props) => <Popout {...props} tldr />,
Warning: (props) => <Popout {...props} warning />,
2023-09-29 16:01:27 +02:00
}
const extra = {
pre: (props) => <Highlight {...props} />,
2023-09-29 16:01:27 +02:00
YouTube,
// This Figure component causes hydration errors
//img: Figure,
table: (props) => (
<table {...props} className="mdx-table table-auto w-full">
{props.children}
</table>
),
ControlTip,
Example,
DocsTitle: (props) => <DocsTitle {...props} site={site} />,
2023-05-22 16:41:15 +02:00
DocsLink: (props) => <DocsLink {...props} site={site} />,
}
2023-09-29 16:01:27 +02:00
if (site === 'sde') return base
if (site === 'dev')
return {
...base,
...extra,
Method: HttpMethod,
StatusCode: HttpStatusCode,
}
const specific = {}
if (
site === 'org' &&
slug &&
slug.length === 2 &&
slug[0] === 'designs' &&
collection.includes(slug[1])
)
specific.DesignInfo = DesignInfo
2023-09-29 16:01:27 +02:00
return {
...base,
...extra,
...specific,
//PatternDocs: WipWithReadMore,
//PatternOptions: WipWithReadMore,
//PatternMeasurements: WipWithReadMore,
//Gauge: V3Wip,
//Legend,
2023-09-29 16:01:27 +02:00
}
}