// Hooks import { useApp } from 'shared/hooks/use-app.mjs' // Dependencies import Head from 'next/head' import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import { mdxLoader } from 'shared/mdx/loader.mjs' import { jargon } from 'site/jargon.mjs' import { mdxPaths } from 'site/prebuild/mdx.paths.mjs' import mdxMeta from 'site/prebuild/mdx.js' // Components import { MdxWrapper } from 'shared/components/wrappers/mdx.mjs' import { TocWrapper } from 'shared/components/wrappers/toc.mjs' import { PageWrapper } from 'shared/components/wrappers/page.mjs' import { components } from 'site/components/mdx/index.mjs' const MdxPage = (props) => { // This hook is used for shared code and global state const app = useApp(props) const title = props.page.title const fullTitle = title + ' - FreeSewing.org' /* * 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 ( {fullTitle}
{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({ locale }) { const { mdx, intro, toc, frontmatter } = await mdxLoader(locale, 'org', 'docs', jargon[locale]) return { props: { mdx, toc, intro: intro.join(' '), page: { path: ['docs'], ...mdxMeta[locale]['docs'], }, ...(await serverSideTranslations(locale)), }, } }