2023-05-20 14:06:39 +02:00
|
|
|
// Dependencies
|
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
|
|
|
// Hooks
|
|
|
|
import { useState, useEffect } from 'react'
|
|
|
|
// Components
|
|
|
|
import { ns } from 'shared/components/wrappers/page.mjs'
|
|
|
|
import { components } from 'shared/components/mdx/index.mjs'
|
|
|
|
//import { TocWrapper } from 'shared/components/wrappers/toc.mjs'
|
2023-05-20 14:28:15 +02:00
|
|
|
import { Loading, Page } from './[...slug].mjs'
|
2023-05-20 14:06:39 +02:00
|
|
|
|
|
|
|
const DocsHomePage = ({ page, slug, locale }) => {
|
|
|
|
// State
|
|
|
|
const [frontmatter, setFrontmatter] = useState({ title: 'FreeSewing.org' })
|
|
|
|
const [MDX, setMDX] = useState(<Loading />)
|
|
|
|
|
|
|
|
/* Load MDX dynamically */
|
|
|
|
useEffect(() => {
|
|
|
|
const loadMDX = async () => {
|
2023-07-17 11:40:45 -05:00
|
|
|
import(
|
|
|
|
/* webpackInclude: /docs\/\w+\.md/ */ `../../../../markdown/org/docs/${locale}.md`
|
|
|
|
).then((mod) => {
|
2023-05-20 14:06:39 +02:00
|
|
|
setFrontmatter(mod.frontmatter)
|
|
|
|
const Component = mod.default
|
2023-06-17 17:49:58 +02:00
|
|
|
setMDX(<Component components={components('org')} />)
|
2023-05-20 14:06:39 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
loadMDX()
|
2023-06-17 17:52:36 +02:00
|
|
|
}, [slug, locale])
|
2023-05-20 14:06:39 +02:00
|
|
|
|
|
|
|
return <Page {...{ page, slug, frontmatter, MDX, locale }} />
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DocsHomePage
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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('en', ['docs', ...ns])),
|
|
|
|
slug: 'docs',
|
|
|
|
locale,
|
|
|
|
page: {
|
|
|
|
locale,
|
|
|
|
path: ['docs'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|