1
0
Fork 0
freesewing/sites/org/pages/docs/index.mjs

57 lines
1.6 KiB
JavaScript
Raw Normal View History

// Hooks
import { useApp } from 'site/hooks/useApp.mjs'
// Dependencies
import Head from 'next/head'
2022-06-10 12:25:56 +02:00
import mdxLoader from 'shared/mdx/loader'
// Components
import { PageWrapper } from 'site/components/wrappers/page.mjs'
import { MdxWrapper } from 'shared/components/wrappers/mdx.mjs'
import { ReadMore } from 'shared/components/mdx/read-more.mjs'
2022-12-26 15:35:22 +01:00
import { jargon } from 'site/jargon.mjs'
2022-06-10 12:25:56 +02:00
2023-01-09 21:37:05 +01:00
const DocsPage = ({ title, mdx, bugsnag }) => {
const app = useApp({ bugsnag })
const fullTitle = title + ' - FreeSewing.org'
2022-06-10 12:25:56 +02:00
// We don't need all MDX components here, just ReadMore
const components = {
2022-12-03 11:25:02 -06:00
ReadMore: (props) => <ReadMore {...props} app={app} slug="docs" recurse />,
2022-06-10 12:25:56 +02:00
}
return (
<PageWrapper app={app} title={title}>
<Head>
<title>{fullTitle}</title>
</Head>
2022-06-10 12:25:56 +02:00
<div className="w-full">
<MdxWrapper mdx={mdx} app={app} components={components} />
</div>
</PageWrapper>
2022-06-10 12:25:56 +02:00
)
}
export default DocsPage
/*
* 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 }) {
2022-12-26 15:35:22 +01:00
const { mdx, frontmatter } = await mdxLoader(locale, 'org', ['docs'], jargon[locale])
2022-12-03 11:25:02 -06:00
const { title = 'FIXME: Please give this page a title' } = frontmatter
2022-06-10 12:25:56 +02:00
return {
props: {
mdx,
title,
2022-12-03 11:25:02 -06:00
},
2022-06-10 12:25:56 +02:00
}
}