diff --git a/packages/freesewing.org/pages/[...mdxslug].js b/packages/freesewing.org/pages/[...mdxslug].js index 27f390155ba..be94a300358 100644 --- a/packages/freesewing.org/pages/[...mdxslug].js +++ b/packages/freesewing.org/pages/[...mdxslug].js @@ -1,10 +1,13 @@ -import Page from 'shared/components/wrappers/page.js' +import Page from 'site/components/wrappers/page.js' import useApp from 'site/hooks/useApp.js' import mdxMeta from 'site/prebuild/mdx.en.js' import mdxLoader from 'shared/mdx/loader' import MdxWrapper from 'shared/components/wrappers/mdx' +import TocWrapper from 'shared/components/wrappers/toc' import Head from 'next/head' import HelpUs from 'site/components/help-us.js' +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' +import components from 'site/components/mdx/index.js' const MdxPage = props => { @@ -27,16 +30,24 @@ const MdxPage = props => { - + - + - + - - +
+ {props.toc && ( +
+ +
+ )} +
+ +
+
) } @@ -58,13 +69,14 @@ export default MdxPage * * To learn more, see: https://nextjs.org/docs/basic-features/data-fetching */ -export async function getStaticProps({ params }) { +export async function getStaticProps({ params, locale }) { - const { mdx, intro } = await mdxLoader('en', 'org', params.mdxslug.join('/')) + const { mdx, intro, toc } = await mdxLoader('en', 'org', params.mdxslug.join('/')) return { props: { mdx, + toc, intro: intro.join(' '), page: { slug: params.mdxslug.join('/'), @@ -72,7 +84,8 @@ export async function getStaticProps({ params }) { slugArray: params.mdxslug, ...mdxMeta[params.mdxslug.join('/')], }, - params + params, + ...(await serverSideTranslations('en')), } } } @@ -94,3 +107,4 @@ export async function getStaticPaths() { fallback: false } } + diff --git a/packages/freesewing.org/pages/docs/[...mdxslug].js b/packages/freesewing.org/pages/docs/[...mdxslug].js deleted file mode 100644 index b6169dbce07..00000000000 --- a/packages/freesewing.org/pages/docs/[...mdxslug].js +++ /dev/null @@ -1,110 +0,0 @@ -import Page from 'site/components/wrappers/page.js' -import useApp from 'site/hooks/useApp.js' -import mdxMeta from 'site/prebuild/mdx.en.js' -import mdxLoader from 'shared/mdx/loader' -import MdxWrapper from 'shared/components/wrappers/mdx' -import TocWrapper from 'shared/components/wrappers/toc' -import Head from 'next/head' -import HelpUs from 'site/components/help-us.js' -import { serverSideTranslations } from 'next-i18next/serverSideTranslations' - -const MdxPage = props => { - - // This hook is used for shared code and global state - const app = useApp() - - /* - * Each page should be wrapped in the Page wrapper component - * You MUST pass it the result of useApp() as the `app` prop - * and for MDX pages you can spread the props.page props to it - * to automatically set the title and navigation - * - * Like breadcrumbs and updating the primary navigation with - * active state - */ - return ( - - - - - - - - - - - - - - -
- {props.toc && ( -
- -
- )} -
- - -
-
-
- ) -} - -/* - * Default export is the NextJS page object - */ -export default MdxPage - - -/* - * getStaticProps() is used to fetch data at build-time. - * - * On this page, it is loading the mdx (markdown) content - * from the markdown file on disk. - * - * This, in combination with getStaticPaths() below means this - * page will be used to render/generate all markdown/mdx content. - * - * To learn more, see: https://nextjs.org/docs/basic-features/data-fetching - */ -export async function getStaticProps({ params, locale }) { - - const { mdx, intro, toc } = await mdxLoader('en', 'dev', params.mdxslug.join('/')) - - return { - props: { - mdx, - toc, - intro: intro.join(' '), - page: { - slug: params.mdxslug.join('/'), - path: '/' + params.mdxslug.join('/'), - slugArray: params.mdxslug, - ...mdxMeta[params.mdxslug.join('/')], - }, - params, - ...(await serverSideTranslations('en')), - } - } -} - -/* - * getStaticPaths() is used to specify for which routes (think URLs) - * this page should be used to generate the result. - * - * On this page, it is returning a list of routes (think URLs) for all - * the mdx (markdown) content. - * That list comes from mdxMeta, which is build in the prebuild step - * and contains paths, titles, and intro for all markdown. - * - * To learn more, see: https://nextjs.org/docs/basic-features/data-fetching - */ -export async function getStaticPaths() { - return { - paths: Object.keys(mdxMeta).map(slug => '/'+slug), - fallback: false - } -} - diff --git a/packages/freesewing.org/pages/docs/index.js b/packages/freesewing.org/pages/docs/index.js new file mode 100644 index 00000000000..49140ad1373 --- /dev/null +++ b/packages/freesewing.org/pages/docs/index.js @@ -0,0 +1,99 @@ +import { useEffect } from 'react' +import Page from 'shared/components/wrappers/page.js' +import useApp from 'site/hooks/useApp.js' +import Popout from 'shared/components/popout.js' + +const TypographyPage = (props) => { + const app = useApp() + const { updateNavigation } = app + + useEffect(() => { + updateNavigation( + ['typography'], + { + __title: 'Typography', + __linktitle: 'Typography', + __slug: 'typography', + __order: 'typography' + }) + }, [updateNavigation]) + + const p = ( +

+ This paragraph is here to show the vertical spacing between headings and paragraphs. + In addition, let's make it a bit longer so we can see the line height as the text wraps. +

+ ) + + return ( + +
+

This typography page shows an overview of different elements and how they are styled.

+

It's a good starting point for theme development.

+

Headings (this is h2)

+ {p} +

This is h3

{p} +

This is h4

{p} +
This is h5
{p} +
This is h6
{p} +

Links and buttons

+

A regular link looks like this, whereas buttons look like this:

+

Main button styles

+
+ + + + +
+

State button styles

+
+ + + + +
+

Other button styles

+
+ + +
+

Outlined button styles

+
+ + + + +
+

Button sizes

+
+ + + + + + + + +
+

Popouts

+

The Popout component is what powers various custom MDX components under the hood:

+ {['note', 'tip', 'warning', 'fixme', 'link', 'related', 'none'].map(type => { + const props = {} + props[type] = true + return ( +
+

{type}

+ +
I am the {type} title
+ {p} +
+
+ ) + })} +
+
+ ) +} + +export default TypographyPage +