diff --git a/sites/dev/components/navigation/sections-menu.mjs b/sites/dev/components/navigation/sections-menu.mjs index d81f84c788c..a777339f9a3 100644 --- a/sites/dev/components/navigation/sections-menu.mjs +++ b/sites/dev/components/navigation/sections-menu.mjs @@ -3,7 +3,7 @@ import Link from 'next/link' import { icons, ns as sectionsNs } from 'shared/components/navigation/primary.mjs' import { useTranslation } from 'next-i18next' import orderBy from 'lodash.orderby' -import { colors } from 'site/components/header/index.mjs' +import { colors } from 'shared/components/header.mjs' import { NavigationContext } from 'shared/context/navigation-context.mjs' import { HelpIcon } from 'shared/components/icons.mjs' diff --git a/sites/shared/components/mdx/index.mjs b/sites/shared/components/mdx/index.mjs index 91f51a0448a..0cd966ab710 100644 --- a/sites/shared/components/mdx/index.mjs +++ b/sites/shared/components/mdx/index.mjs @@ -34,7 +34,7 @@ export const components = { Tab, Tabs, ControlTip, - // Example, + Example, PatternDocs: Fixme, PatternOptions: Fixme, } diff --git a/sites/shared/components/mdx/tabbed-example.mjs b/sites/shared/components/mdx/tabbed-example.mjs index 987500d30aa..6b1c2c9af16 100644 --- a/sites/shared/components/mdx/tabbed-example.mjs +++ b/sites/shared/components/mdx/tabbed-example.mjs @@ -4,11 +4,10 @@ import { pluginBundle } from '@freesewing/plugin-bundle' import { pluginFlip } from '@freesewing/plugin-flip' import { pluginGore } from '@freesewing/plugin-gore' import { Design } from '@freesewing/core' -//import { Svg } from '../workbench/draft/svg' -//import { Defs } from '../workbench/draft/defs' -//import { Stack } from '../workbench/draft/stack' -import { useGist } from 'shared/hooks/useGist' -import { useEffect } from 'react' +import { Svg } from '../workbench/pattern/svg' +import { Defs } from '../workbench/pattern/defs' +import { Stack } from '../workbench/pattern/stack' +import { useState, useEffect } from 'react' import yaml from 'js-yaml' // Get code from children @@ -23,13 +22,8 @@ export const asText = (reactEl) => { } // The actual example -const Example = ({ app, patternProps, xray = false }) => { - // State for gist - const gist = useMemo(() => { - const newGist = defaultGist('example-mdx', app.locale) - set(newGist, ['_state', 'xray', 'enabled'], xray) - return newGist - }, [xray, app.locale]) +const Example = ({ patternProps, tutorial, paperless, settings, showInfo, xray = false }) => { + const [ui, setUi] = useState({ renderer: 'react', xray: { enabled: xray } }) if (patternProps.logs.pattern.error.length > 0 || patternProps.logs.sets[0].error.length > 0) return ( @@ -40,14 +34,13 @@ const Example = ({ app, patternProps, xray = false }) => { ) return ( - + {Object.keys(patternProps.stacks).map((stackName) => ( { - // FIXME: Deal with this later - return null if (settings) settings = { margin: 5, @@ -130,10 +120,10 @@ export const TabbedExample = ({ {children} - + - + {caption && ( @@ -148,11 +138,11 @@ export const TabbedExample = ({
- + {children} - + {caption && ( diff --git a/sites/shared/components/workbench/pattern/path.mjs b/sites/shared/components/workbench/pattern/path.mjs index e8f545def9f..a91cbdebbc3 100644 --- a/sites/shared/components/workbench/pattern/path.mjs +++ b/sites/shared/components/workbench/pattern/path.mjs @@ -1,6 +1,6 @@ // Dependencies import { getProps } from './utils.mjs' -import { round, formatMm } from 'shared/utils.mjs' +import { round, formatMm, getId } from 'shared/utils.mjs' // Hooks import { useTranslation } from 'next-i18next' // Components @@ -596,7 +596,11 @@ export const Path = ({ pathName, path, partName, part, units, showInfo, ui, upda output.push() if (path.attributes.get('data-text')) output.push( - + ) if (ui.xray?.enabled) output.push() diff --git a/sites/shared/config/next.mjs b/sites/shared/config/next.mjs index 78127da61c0..361d336037b 100644 --- a/sites/shared/config/next.mjs +++ b/sites/shared/config/next.mjs @@ -52,7 +52,7 @@ const getMdxConfig = ({ site, jargon }) => ({ [ rehypeHighlight, { - plainText: ['dot', 'http'], + plainText: ['dot', 'http', 'mermaid'], aliases: { javascript: [ 'design/src/index.mjs', diff --git a/sites/shared/page-templates/docs.dev.mjs.mustache b/sites/shared/page-templates/docs.dev.mjs.mustache new file mode 100644 index 00000000000..5801f5517b8 --- /dev/null +++ b/sites/shared/page-templates/docs.dev.mjs.mustache @@ -0,0 +1,68 @@ +// Hooks +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' +// Components +import Head from 'next/head' +import { MdxWrapper } from 'shared/components/wrappers/mdx.mjs' +//import { TocWrapper } from 'shared/components/wrappers/toc.mjs' +import { PageWrapper, ns } from 'shared/components/wrappers/page.mjs' +// MDX content +import MDX, { frontmatter } from 'markdown/{{{ slug }}}/en.md' + +/* + * This page is auto-generated by the prebuild script. + * Any changes you make will be overwritten on the next (pre)build. + * + * See the page-templates folder for more info. + */ +const DocsPage = ({ page, locale }) => ( + + + + + + + + + + + + + + {frontmatter.title} - FreeSewing.org + +
+ {frontmatter.toc && ( +
+ {/* FIXME: Implement toc plugin to add it to the frontmatter */} + {/* */} +
+ )} + +
+
+) + +export default DocsPage + +/* + * getStaticProps() is used to fetch data at build-time. + * To learn more, see: https://nextjs.org/docs/basic-features/data-fetching + */ +export async function getStaticProps({ locale }) { + return { + props: { + ...(await serverSideTranslations(locale, ['docs', ...ns])), + locale, + page: { + locale, + path: {{{ slugArray }}}, + }, + }, + } +} diff --git a/sites/shared/page-templates/docs.mjs.mustache b/sites/shared/page-templates/docs.org.mjs.mustache similarity index 100% rename from sites/shared/page-templates/docs.mjs.mustache rename to sites/shared/page-templates/docs.org.mjs.mustache diff --git a/sites/shared/prebuild/docs.mjs b/sites/shared/prebuild/docs.mjs index a8a1668e569..e4ba1f9c56f 100644 --- a/sites/shared/prebuild/docs.mjs +++ b/sites/shared/prebuild/docs.mjs @@ -99,7 +99,7 @@ export const prebuildDocs = async (site) => { // Load page template const template = fs.readFileSync( - path.resolve('..', 'shared', 'page-templates', `docs.mjs.mustache`), + path.resolve('..', 'shared', 'page-templates', `docs.${site}.mjs.mustache`), 'utf-8' ) @@ -147,11 +147,11 @@ export const prebuildDocs = async (site) => { mustache.render(template, { slug, slugArray: JSON.stringify(slug.split('/')), - introEN: intros.en, - introES: intros.es, - introDE: intros.de, - introFR: intros.fr, - introNL: intros.nl, + introEN: intros.en || 'fixme', + introES: intros.es || 'fixme', + introDE: intros.de || 'fixme', + introFR: intros.fr || 'fixme', + introNL: intros.nl || 'fixme', }) ) } diff --git a/sites/shared/utils.mjs b/sites/shared/utils.mjs index 8e633c85c24..75ea0b41cad 100644 --- a/sites/shared/utils.mjs +++ b/sites/shared/utils.mjs @@ -4,6 +4,10 @@ import set from 'lodash.set' import orderBy from 'lodash.orderby' import unset from 'lodash.unset' +// Method that returns a unique ID when all you need is an ID +// but you can't be certain you have one +export const getId = (id) => (id ? id : Date.now()) + // Generic rounding method export const round = (val, decimals = 1) => Math.round(val * Math.pow(10, decimals)) / Math.pow(10, decimals)