chore(lab): Fixed issues with next build
This commit is contained in:
parent
8df1276430
commit
7c8b59b781
9 changed files with 99 additions and 33 deletions
|
@ -3,7 +3,7 @@ import Link from 'next/link'
|
||||||
import { icons, ns as sectionsNs } from 'shared/components/navigation/primary.mjs'
|
import { icons, ns as sectionsNs } from 'shared/components/navigation/primary.mjs'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import orderBy from 'lodash.orderby'
|
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 { NavigationContext } from 'shared/context/navigation-context.mjs'
|
||||||
import { HelpIcon } from 'shared/components/icons.mjs'
|
import { HelpIcon } from 'shared/components/icons.mjs'
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ export const components = {
|
||||||
Tab,
|
Tab,
|
||||||
Tabs,
|
Tabs,
|
||||||
ControlTip,
|
ControlTip,
|
||||||
// Example,
|
Example,
|
||||||
PatternDocs: Fixme,
|
PatternDocs: Fixme,
|
||||||
PatternOptions: Fixme,
|
PatternOptions: Fixme,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,10 @@ import { pluginBundle } from '@freesewing/plugin-bundle'
|
||||||
import { pluginFlip } from '@freesewing/plugin-flip'
|
import { pluginFlip } from '@freesewing/plugin-flip'
|
||||||
import { pluginGore } from '@freesewing/plugin-gore'
|
import { pluginGore } from '@freesewing/plugin-gore'
|
||||||
import { Design } from '@freesewing/core'
|
import { Design } from '@freesewing/core'
|
||||||
//import { Svg } from '../workbench/draft/svg'
|
import { Svg } from '../workbench/pattern/svg'
|
||||||
//import { Defs } from '../workbench/draft/defs'
|
import { Defs } from '../workbench/pattern/defs'
|
||||||
//import { Stack } from '../workbench/draft/stack'
|
import { Stack } from '../workbench/pattern/stack'
|
||||||
import { useGist } from 'shared/hooks/useGist'
|
import { useState, useEffect } from 'react'
|
||||||
import { useEffect } from 'react'
|
|
||||||
import yaml from 'js-yaml'
|
import yaml from 'js-yaml'
|
||||||
|
|
||||||
// Get code from children
|
// Get code from children
|
||||||
|
@ -23,13 +22,8 @@ export const asText = (reactEl) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The actual example
|
// The actual example
|
||||||
const Example = ({ app, patternProps, xray = false }) => {
|
const Example = ({ patternProps, tutorial, paperless, settings, showInfo, xray = false }) => {
|
||||||
// State for gist
|
const [ui, setUi] = useState({ renderer: 'react', xray: { enabled: xray } })
|
||||||
const gist = useMemo(() => {
|
|
||||||
const newGist = defaultGist('example-mdx', app.locale)
|
|
||||||
set(newGist, ['_state', 'xray', 'enabled'], xray)
|
|
||||||
return newGist
|
|
||||||
}, [xray, app.locale])
|
|
||||||
|
|
||||||
if (patternProps.logs.pattern.error.length > 0 || patternProps.logs.sets[0].error.length > 0)
|
if (patternProps.logs.pattern.error.length > 0 || patternProps.logs.sets[0].error.length > 0)
|
||||||
return (
|
return (
|
||||||
|
@ -40,14 +34,13 @@ const Example = ({ app, patternProps, xray = false }) => {
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Svg {...patternProps} embed={true}>
|
<Svg {...patternProps} settings={settings} embed={true}>
|
||||||
<Defs {...patternProps} />
|
<Defs {...patternProps} />
|
||||||
<style>{`:root { --pattern-scale: 1} ${patternProps.svg.style}`}</style>
|
<style>{`:root { --pattern-scale: 1} ${patternProps.svg.style}`}</style>
|
||||||
<g>
|
<g>
|
||||||
{Object.keys(patternProps.stacks).map((stackName) => (
|
{Object.keys(patternProps.stacks).map((stackName) => (
|
||||||
<Stack
|
<Stack
|
||||||
{...{ app, gist, patternProps }}
|
{...{ showInfo, patternProps, settings, ui }}
|
||||||
showInfo={app.setPopup}
|
|
||||||
key={stackName}
|
key={stackName}
|
||||||
stackName={stackName}
|
stackName={stackName}
|
||||||
stack={patternProps.stacks[stackName]}
|
stack={patternProps.stacks[stackName]}
|
||||||
|
@ -98,7 +91,6 @@ const buildExample = (children, settings = { margin: 5 }, tutorial = false, pape
|
||||||
|
|
||||||
// Wrapper component dealing with the tabs and code view
|
// Wrapper component dealing with the tabs and code view
|
||||||
export const TabbedExample = ({
|
export const TabbedExample = ({
|
||||||
app,
|
|
||||||
children,
|
children,
|
||||||
caption,
|
caption,
|
||||||
tutorial,
|
tutorial,
|
||||||
|
@ -107,8 +99,6 @@ export const TabbedExample = ({
|
||||||
paperless,
|
paperless,
|
||||||
settings,
|
settings,
|
||||||
}) => {
|
}) => {
|
||||||
// FIXME: Deal with this later
|
|
||||||
return null
|
|
||||||
if (settings)
|
if (settings)
|
||||||
settings = {
|
settings = {
|
||||||
margin: 5,
|
margin: 5,
|
||||||
|
@ -130,10 +120,10 @@ export const TabbedExample = ({
|
||||||
<Tabs tabs="Code, Preview, X-Ray">
|
<Tabs tabs="Code, Preview, X-Ray">
|
||||||
<Tab key="code">{children}</Tab>
|
<Tab key="code">{children}</Tab>
|
||||||
<Tab key="preview">
|
<Tab key="preview">
|
||||||
<Example {...{ patternProps, tutorial, paperless, settings, app }} />
|
<Example {...{ patternProps, tutorial, paperless, settings }} />
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab key="xray">
|
<Tab key="xray">
|
||||||
<Example {...{ patternProps, tutorial, paperless, settings, app }} xray={true} />
|
<Example {...{ patternProps, tutorial, paperless, settings }} xray={true} />
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
{caption && (
|
{caption && (
|
||||||
|
@ -148,11 +138,11 @@ export const TabbedExample = ({
|
||||||
<div className="my-8">
|
<div className="my-8">
|
||||||
<Tabs tabs="Preview, Code, X-Ray">
|
<Tabs tabs="Preview, Code, X-Ray">
|
||||||
<Tab key="preview">
|
<Tab key="preview">
|
||||||
<Example {...{ patternProps, tutorial, paperless, settings, app }} />
|
<Example {...{ patternProps, tutorial, paperless, settings }} />
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab key="code">{children}</Tab>
|
<Tab key="code">{children}</Tab>
|
||||||
<Tab key="xray">
|
<Tab key="xray">
|
||||||
<Example {...{ patternProps, tutorial, paperless, settings, app }} xray={true} />
|
<Example {...{ patternProps, tutorial, paperless, settings }} xray={true} />
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
{caption && (
|
{caption && (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { getProps } from './utils.mjs'
|
import { getProps } from './utils.mjs'
|
||||||
import { round, formatMm } from 'shared/utils.mjs'
|
import { round, formatMm, getId } from 'shared/utils.mjs'
|
||||||
// Hooks
|
// Hooks
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
// Components
|
// Components
|
||||||
|
@ -596,7 +596,11 @@ export const Path = ({ pathName, path, partName, part, units, showInfo, ui, upda
|
||||||
output.push(<path id={pathId} key={pathId} d={d} {...getProps(path)} />)
|
output.push(<path id={pathId} key={pathId} d={d} {...getProps(path)} />)
|
||||||
if (path.attributes.get('data-text'))
|
if (path.attributes.get('data-text'))
|
||||||
output.push(
|
output.push(
|
||||||
<TextOnPath key={'text-on-path-' + name} pathId={pathId} {...{ path, ui, showInfo }} />
|
<TextOnPath
|
||||||
|
key={'text-on-path-' + getId(pathId)}
|
||||||
|
pathId={pathId}
|
||||||
|
{...{ path, ui, showInfo }}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
if (ui.xray?.enabled) output.push(<XrayPath key={'xpath' + pathId} />)
|
if (ui.xray?.enabled) output.push(<XrayPath key={'xpath' + pathId} />)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ const getMdxConfig = ({ site, jargon }) => ({
|
||||||
[
|
[
|
||||||
rehypeHighlight,
|
rehypeHighlight,
|
||||||
{
|
{
|
||||||
plainText: ['dot', 'http'],
|
plainText: ['dot', 'http', 'mermaid'],
|
||||||
aliases: {
|
aliases: {
|
||||||
javascript: [
|
javascript: [
|
||||||
'design/src/index.mjs',
|
'design/src/index.mjs',
|
||||||
|
|
68
sites/shared/page-templates/docs.dev.mjs.mustache
Normal file
68
sites/shared/page-templates/docs.dev.mjs.mustache
Normal file
|
@ -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 }) => (
|
||||||
|
<PageWrapper {...page} title={frontmatter.title}>
|
||||||
|
<Head>
|
||||||
|
<meta property="og:title" content={frontmatter.title} key="title" />
|
||||||
|
<meta property="og:type" content="article" key="type" />
|
||||||
|
<meta property="og:description" content={ `{{{ introEn }}}` } key="type" />
|
||||||
|
<meta property="og:article:author" content="Joost De Cock" key="author" />
|
||||||
|
<meta
|
||||||
|
property="og:image"
|
||||||
|
content={`https://canary.backend.freesewing.org/og-img/${page.locale}/org/{{{ slug }}}}`}
|
||||||
|
key="image"
|
||||||
|
/>
|
||||||
|
<meta property="og:image:type" content="image/png" />
|
||||||
|
<meta property="og:image:width" content="1200" />
|
||||||
|
<meta property="og:image:height" content="630" />
|
||||||
|
<meta property="og:url" content={`https://${page.locale === 'en'
|
||||||
|
? ''
|
||||||
|
: page.locale+'/'}freesewing.org/{{{ slug }}}`} key="url" />
|
||||||
|
<meta property="og:locale" content={page.locale} key="locale" />
|
||||||
|
<meta property="og:site_name" content="freesewing.org" key="site" />
|
||||||
|
<title>{frontmatter.title} - FreeSewing.org</title>
|
||||||
|
</Head>
|
||||||
|
<div className="flex flex-row-reverse flex-wrap xl:flex-nowrap justify-end">
|
||||||
|
{frontmatter.toc && (
|
||||||
|
<div className="mb-8 w-full xl:w-80 2xl:w-96 xl:pl-8 2xl:pl-16">
|
||||||
|
{/* FIXME: Implement toc plugin to add it to the frontmatter */}
|
||||||
|
{/* <TocWrapper toc={frontmatter.toc} /> */}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<MdxWrapper {...{ MDX, frontmatter }} />
|
||||||
|
</div>
|
||||||
|
</PageWrapper>
|
||||||
|
)
|
||||||
|
|
||||||
|
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 }}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
|
@ -99,7 +99,7 @@ export const prebuildDocs = async (site) => {
|
||||||
|
|
||||||
// Load page template
|
// Load page template
|
||||||
const template = fs.readFileSync(
|
const template = fs.readFileSync(
|
||||||
path.resolve('..', 'shared', 'page-templates', `docs.mjs.mustache`),
|
path.resolve('..', 'shared', 'page-templates', `docs.${site}.mjs.mustache`),
|
||||||
'utf-8'
|
'utf-8'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -147,11 +147,11 @@ export const prebuildDocs = async (site) => {
|
||||||
mustache.render(template, {
|
mustache.render(template, {
|
||||||
slug,
|
slug,
|
||||||
slugArray: JSON.stringify(slug.split('/')),
|
slugArray: JSON.stringify(slug.split('/')),
|
||||||
introEN: intros.en,
|
introEN: intros.en || 'fixme',
|
||||||
introES: intros.es,
|
introES: intros.es || 'fixme',
|
||||||
introDE: intros.de,
|
introDE: intros.de || 'fixme',
|
||||||
introFR: intros.fr,
|
introFR: intros.fr || 'fixme',
|
||||||
introNL: intros.nl,
|
introNL: intros.nl || 'fixme',
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,10 @@ import set from 'lodash.set'
|
||||||
import orderBy from 'lodash.orderby'
|
import orderBy from 'lodash.orderby'
|
||||||
import unset from 'lodash.unset'
|
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
|
// Generic rounding method
|
||||||
export const round = (val, decimals = 1) =>
|
export const round = (val, decimals = 1) =>
|
||||||
Math.round(val * Math.pow(10, decimals)) / Math.pow(10, decimals)
|
Math.round(val * Math.pow(10, decimals)) / Math.pow(10, decimals)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue