2023-01-29 16:44:02 +01:00
|
|
|
// Dependencies
|
2023-04-16 16:19:49 +02:00
|
|
|
import Head from 'next/head'
|
2023-03-28 16:47:07 +02:00
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
2023-04-16 16:19:49 +02:00
|
|
|
import { mdxLoader } from 'shared/mdx/loader.mjs'
|
|
|
|
import { jargon } from 'site/jargon.mjs'
|
|
|
|
import mdxMeta from 'site/prebuild/mdx.js'
|
2023-01-29 16:44:02 +01:00
|
|
|
// Components
|
|
|
|
import { MdxWrapper } from 'shared/components/wrappers/mdx.mjs'
|
2023-04-16 16:19:49 +02:00
|
|
|
import { TocWrapper } from 'shared/components/wrappers/toc.mjs'
|
2023-04-28 21:23:06 +02:00
|
|
|
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
|
2023-04-16 16:19:49 +02:00
|
|
|
import { components } from 'site/components/mdx/index.mjs'
|
2022-06-10 12:25:56 +02:00
|
|
|
|
2023-04-28 21:23:06 +02:00
|
|
|
// Translation namespaces used on this page
|
|
|
|
const namespaces = [...new Set(['docs', ...pageNs])]
|
2022-06-10 12:25:56 +02:00
|
|
|
|
2023-04-28 21:23:06 +02:00
|
|
|
/*
|
|
|
|
* Each page MUST be wrapped in the PageWrapper component.
|
|
|
|
* You also MUST spread props.page into this wrapper component
|
|
|
|
* when path and locale come from static props (as here)
|
|
|
|
* or set them manually.
|
|
|
|
*/
|
|
|
|
const DocsIndexPage = ({ page, mdx, toc, intro }) => (
|
|
|
|
<PageWrapper {...page}>
|
|
|
|
<Head>
|
|
|
|
<meta property="og:title" content={page.t} key="title" />
|
|
|
|
<meta property="og:type" content="article" key="type" />
|
|
|
|
<meta property="og:description" content={intro} 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/en/dev/${page.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://freesewing.dev/${page.slug}`} key="url" />
|
|
|
|
<meta property="og:locale" content="en_US" key="locale" />
|
|
|
|
<meta property="og:site_name" content="freesewing.dev" key="site" />
|
|
|
|
<title>{typeof page.t === 'string' ? page.t : ''} - FreeSewing.org</title>
|
|
|
|
</Head>
|
|
|
|
<div className="flex flex-row-reverse flex-wrap xl:flex-nowrap justify-end">
|
|
|
|
{toc && (
|
|
|
|
<div className="mb-8 w-full xl:w-80 2xl:w-96 xl:pl-8 2xl:pl-16">
|
|
|
|
<TocWrapper toc={toc} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className="max-w-prose">
|
|
|
|
<MdxWrapper mdx={mdx} components={components} />
|
2023-04-09 15:57:25 +02:00
|
|
|
</div>
|
2023-04-28 21:23:06 +02:00
|
|
|
</div>
|
|
|
|
</PageWrapper>
|
|
|
|
)
|
2022-06-10 12:25:56 +02:00
|
|
|
|
2023-04-16 16:19:49 +02:00
|
|
|
/*
|
|
|
|
* Default export is the NextJS page object
|
|
|
|
*/
|
2023-04-28 21:23:06 +02:00
|
|
|
export default DocsIndexPage
|
2022-06-10 12:25:56 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2022-12-03 11:25:02 -06:00
|
|
|
export async function getStaticProps({ locale }) {
|
2023-04-16 17:13:18 +02:00
|
|
|
const { mdx, intro, toc } = await mdxLoader(locale, 'org', 'docs', jargon[locale])
|
2022-06-10 12:25:56 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
mdx,
|
2023-04-16 16:19:49 +02:00
|
|
|
toc,
|
|
|
|
intro: intro.join(' '),
|
2023-03-28 16:47:07 +02:00
|
|
|
page: {
|
|
|
|
path: ['docs'],
|
2023-04-28 21:23:06 +02:00
|
|
|
locale,
|
2023-04-16 16:19:49 +02:00
|
|
|
...mdxMeta[locale]['docs'],
|
2023-03-28 16:47:07 +02:00
|
|
|
},
|
2023-04-28 21:23:06 +02:00
|
|
|
...(await serverSideTranslations(locale, namespaces)),
|
2022-12-03 11:25:02 -06:00
|
|
|
},
|
2022-06-10 12:25:56 +02:00
|
|
|
}
|
|
|
|
}
|