From aeeca8864158114ce8b3856dc527f82b51bee682 Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Fri, 10 Jun 2022 12:25:56 +0200 Subject: [PATCH] wip(org): Changes to page structure --- packages/freesewing.org/pages/blog/[slug].js | 10 +++- .../pages/{ => docs}/[...mdxslug].js | 10 +++- packages/freesewing.org/pages/docs/index.js | 54 +++++++++++++++++++ 3 files changed, 70 insertions(+), 4 deletions(-) rename packages/freesewing.org/pages/{ => docs}/[...mdxslug].js (94%) create mode 100644 packages/freesewing.org/pages/docs/index.js diff --git a/packages/freesewing.org/pages/blog/[slug].js b/packages/freesewing.org/pages/blog/[slug].js index 8f082e1b7b2..864928bd804 100644 --- a/packages/freesewing.org/pages/blog/[slug].js +++ b/packages/freesewing.org/pages/blog/[slug].js @@ -159,11 +159,17 @@ export const getStaticPaths = async () => { `${strapiHost}/blogposts?_locale=en&dev_ne=true&_limit=-1` ) .then(response => response.json()) - .then(data => data.map(post => ({ params: { slug: post.slug } }))) + .then(data => data.map(post => `/blog/${post.slug}`)) .catch(err => console.log(err)) return { - paths, + paths: [ + ...paths, + ...paths.map(p => `/de${p}`), + ...paths.map(p => `/es${p}`), + ...paths.map(p => `/fr${p}`), + ...paths.map(p => `/nl${p}`), + ], fallback: false, } } diff --git a/packages/freesewing.org/pages/[...mdxslug].js b/packages/freesewing.org/pages/docs/[...mdxslug].js similarity index 94% rename from packages/freesewing.org/pages/[...mdxslug].js rename to packages/freesewing.org/pages/docs/[...mdxslug].js index f2c2c1b5e8b..6039a1902a6 100644 --- a/packages/freesewing.org/pages/[...mdxslug].js +++ b/packages/freesewing.org/pages/docs/[...mdxslug].js @@ -70,7 +70,11 @@ export default MdxPage */ export async function getStaticProps({ params, locale }) { - const { mdx, intro, toc, frontmatter } = await mdxLoader(locale, 'org', params.mdxslug.join('/')) + const { mdx, intro, toc, frontmatter } = await mdxLoader( + locale, + 'org', + ['docs', ...params.mdxslug].join('/') + ) const { title='FIXME: Please give this page a title' } = frontmatter return { @@ -104,7 +108,9 @@ export async function getStaticProps({ params, locale }) { */ export async function getStaticPaths() { - const somePaths = mdxPaths.filter(path => (path.split('/').length < 5)) + const somePaths = mdxPaths + .filter(path => (path.split('/').length < 5)) + .filter(path => (path !== 'docs')) return { paths: [ diff --git a/packages/freesewing.org/pages/docs/index.js b/packages/freesewing.org/pages/docs/index.js new file mode 100644 index 00000000000..9bf3098a8ad --- /dev/null +++ b/packages/freesewing.org/pages/docs/index.js @@ -0,0 +1,54 @@ +import { useEffect } from 'react' +import Page from 'site/components/wrappers/page.js' +import useApp from 'site/hooks/useApp.js' +import mdxLoader from 'shared/mdx/loader' +import MdxWrapper from 'shared/components/wrappers/mdx' +import ReadMore from 'shared/components/mdx/read-more.js' + +const DocsPage = ({ title, mdx }) => { + const app = useApp() + + // We don't need all MDX components here, just ReadMore + const components = { + ReadMore: props => , + } + + return ( + +
+ +
+
+ ) +} + +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 + */ +export async function getStaticProps({ params, locale }) { + + const { mdx, intro, toc, frontmatter } = await mdxLoader( + locale, + 'org', + ['docs'] + ) + const { title='FIXME: Please give this page a title' } = frontmatter + + return { + props: { + mdx, + title, + } + } +} +