2023-09-29 16:01:27 +02:00
|
|
|
// __SDEFILE__ - This file is a dependency for the stand-alone environment
|
2023-07-23 18:42:06 +02:00
|
|
|
import { Popout } from 'shared/components/popout/index.mjs'
|
2023-01-29 16:44:02 +01:00
|
|
|
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'
|
2023-08-28 20:30:00 +02:00
|
|
|
import { Tab, Tabs } from '../tabs.mjs'
|
2023-01-29 16:44:02 +01:00
|
|
|
import { TabbedExample as Example } from './tabbed-example.mjs'
|
|
|
|
import { HttpMethod, HttpStatusCode } from './http.mjs'
|
2023-05-15 15:57:46 +02:00
|
|
|
import { ControlTip } from '../control/tip.mjs'
|
2023-06-17 12:09:07 +02:00
|
|
|
import { DocsTitle, DocsLink } from './docs-helpers.mjs'
|
2023-10-10 15:43:25 +02:00
|
|
|
import { Legend } from './legend.mjs'
|
2023-10-06 09:15:07 +02:00
|
|
|
// Extra components
|
|
|
|
import { DesignInfo } from 'shared/components/designs/info.mjs'
|
|
|
|
import { collection } from 'site/hooks/use-design.mjs'
|
2023-10-10 15:43:25 +02:00
|
|
|
import { DesignMeasurements } from './design-measurements.mjs'
|
|
|
|
import { DesignOptions } from './design-options.mjs'
|
2023-11-11 18:55:28 +01:00
|
|
|
import { MeasieImage } from 'shared/components/measurements/image.mjs'
|
2024-02-17 19:55:56 +01:00
|
|
|
// Dev/Org jargon
|
2024-03-17 19:19:56 +01:00
|
|
|
import { Term as SharedTerm, termList } from 'shared/components/jargon.mjs'
|
|
|
|
import { jargon, site } from 'site/prebuild/jargon.mjs'
|
2024-04-06 13:21:04 +02:00
|
|
|
// Dev web of trust
|
|
|
|
import { WebOfTrustMap, WebOfTrustTable } from '../../../dev/components/web-of-trust.mjs'
|
2024-03-17 19:19:56 +01:00
|
|
|
|
|
|
|
export const Term = ({ children }) => <SharedTerm {...{ jargon, children, site }} />
|
|
|
|
export const TermList = termList(jargon, site)
|
2023-01-27 21:35:45 +01:00
|
|
|
|
2023-10-06 09:15:07 +02:00
|
|
|
export const components = (site = 'org', slug = []) => {
|
2023-05-21 09:41:20 +02:00
|
|
|
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,
|
2023-05-21 09:41:20 +02:00
|
|
|
Tip: (props) => <Popout {...props} tip />,
|
2023-06-16 20:00:26 +02:00
|
|
|
Tldr: (props) => <Popout {...props} tldr />,
|
2023-05-21 09:41:20 +02:00
|
|
|
Warning: (props) => <Popout {...props} warning />,
|
2024-02-17 19:55:56 +01:00
|
|
|
em: (props) => <Term {...props} />,
|
2023-09-29 16:01:27 +02:00
|
|
|
}
|
2024-03-02 14:45:41 +01:00
|
|
|
|
2023-09-29 16:01:27 +02:00
|
|
|
const extra = {
|
2023-05-21 09:41:20 +02:00
|
|
|
pre: (props) => <Highlight {...props} />,
|
2023-09-29 16:01:27 +02:00
|
|
|
YouTube,
|
2023-05-21 09:41:20 +02:00
|
|
|
// This Figure component causes hydration errors
|
|
|
|
//img: Figure,
|
|
|
|
table: (props) => (
|
|
|
|
<table {...props} className="mdx-table table-auto w-full">
|
|
|
|
{props.children}
|
|
|
|
</table>
|
|
|
|
),
|
|
|
|
ControlTip,
|
|
|
|
Example,
|
2023-05-21 10:11:26 +02:00
|
|
|
DocsTitle: (props) => <DocsTitle {...props} site={site} />,
|
2023-05-22 16:41:15 +02:00
|
|
|
DocsLink: (props) => <DocsLink {...props} site={site} />,
|
2023-05-21 09:41:20 +02:00
|
|
|
}
|
|
|
|
|
2023-09-29 16:01:27 +02:00
|
|
|
if (site === 'sde') return base
|
|
|
|
|
2024-03-02 14:45:41 +01:00
|
|
|
// TermList
|
|
|
|
if (site === 'dev' && Array.isArray(slug) && slug.join('/') === 'reference/terms')
|
|
|
|
extra.TermList = TermList
|
|
|
|
else if (site === 'org' && Array.isArray(slug) && slug.join('/') === 'about/terms')
|
|
|
|
extra.TermList = TermList
|
|
|
|
|
2023-09-29 16:01:27 +02:00
|
|
|
if (site === 'dev')
|
|
|
|
return {
|
|
|
|
...base,
|
|
|
|
...extra,
|
|
|
|
Method: HttpMethod,
|
|
|
|
StatusCode: HttpStatusCode,
|
2024-04-06 13:21:04 +02:00
|
|
|
WebOfTrustTable,
|
|
|
|
WebOfTrustMap,
|
2023-09-29 16:01:27 +02:00
|
|
|
}
|
|
|
|
|
2023-10-06 09:15:07 +02:00
|
|
|
const specific = {}
|
2023-11-18 18:25:25 +01:00
|
|
|
if (typeof slug === 'string') slug = slug.split('/')
|
2023-10-06 09:15:07 +02:00
|
|
|
if (
|
|
|
|
site === 'org' &&
|
|
|
|
slug &&
|
2023-10-10 15:43:25 +02:00
|
|
|
slug.length > 1 &&
|
2023-10-06 09:15:07 +02:00
|
|
|
slug[0] === 'designs' &&
|
|
|
|
collection.includes(slug[1])
|
2023-10-10 15:43:25 +02:00
|
|
|
) {
|
|
|
|
if (slug.length === 2) specific.DesignInfo = DesignInfo
|
|
|
|
if (slug.length === 3 && slug[2] === 'measurements')
|
|
|
|
specific.DesignMeasurements = DesignMeasurements
|
|
|
|
if (slug.length === 3 && slug[2] === 'options') specific.DesignOptions = DesignOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if (site === 'org' && Array.isArray(slug)) {
|
|
|
|
const url = slug.join('/')
|
2023-10-12 19:43:27 +02:00
|
|
|
if (url.indexOf('about/notation') !== -1 || url.indexOf('sewing/on-the-fold') !== -1)
|
2023-10-10 15:43:25 +02:00
|
|
|
specific.Legend = Legend
|
|
|
|
}
|
2023-10-06 09:15:07 +02:00
|
|
|
|
2023-11-18 18:37:49 +01:00
|
|
|
// MeasieImage
|
|
|
|
if (site === 'org' && slug) {
|
|
|
|
// Regular MDX - MeasieImage
|
|
|
|
if (slug.length === 2 && slug[0] === 'measurements') {
|
|
|
|
specific.MeasieImage = function MdxMeasieImage() {
|
|
|
|
return <MeasieImage m={slug[1]} />
|
|
|
|
}
|
2023-11-12 11:15:41 +01:00
|
|
|
}
|
2023-11-11 18:55:28 +01:00
|
|
|
|
2023-11-18 18:37:49 +01:00
|
|
|
// Dynamic MDX - MeasieImage
|
|
|
|
if (slug.length === 3 && slug[0] === 'docs' && slug[1] === 'measurements') {
|
|
|
|
specific.MeasieImage = function MdxMeasieImage() {
|
|
|
|
return <MeasieImage m={slug[2]} />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-29 16:01:27 +02:00
|
|
|
return {
|
|
|
|
...base,
|
|
|
|
...extra,
|
2023-10-06 09:15:07 +02:00
|
|
|
...specific,
|
2023-09-29 16:01:27 +02:00
|
|
|
}
|
2023-05-15 15:57:46 +02:00
|
|
|
}
|