2023-07-04 13:28:46 -05:00
|
|
|
import {
|
|
|
|
SanityPageWrapper,
|
|
|
|
getSanityStaticPaths,
|
|
|
|
ns as sanityNs,
|
|
|
|
} from 'site/components/sanity/page-wrapper.mjs'
|
2023-06-19 16:27:13 -05:00
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
2023-07-03 13:28:41 -05:00
|
|
|
import { sanityLoader, sanitySiteImage } from 'site/components/sanity/utils.mjs'
|
2023-06-19 16:27:13 -05:00
|
|
|
|
|
|
|
const namespaces = [...sanityNs]
|
|
|
|
|
|
|
|
const ShowcasePage = (props) => {
|
|
|
|
return <SanityPageWrapper {...props} namespaces={namespaces} />
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* getStaticProps() is used to fetch data at build-time.
|
|
|
|
*
|
|
|
|
* On this page, it is loading the showcase content from strapi.
|
|
|
|
*
|
|
|
|
* This, in combination with getStaticPaths() below means this
|
|
|
|
* page will be used to render/generate all showcase content.
|
|
|
|
*
|
|
|
|
* To learn more, see: https://nextjs.org/docs/basic-features/data-fetching
|
|
|
|
*/
|
|
|
|
export async function getStaticProps({ params, locale }) {
|
|
|
|
const { slug } = params
|
|
|
|
const post = await sanityLoader({ type: 'showcase', language: locale, slug })
|
|
|
|
.then((data) => data[0])
|
|
|
|
.catch((err) => console.log(err))
|
|
|
|
|
|
|
|
const designs = [post.design1 || null]
|
|
|
|
if (post.design2 && post.design2.length > 2) designs.push(post.design2)
|
|
|
|
if (post.design3 && post.design3.length > 2) designs.push(post.design3)
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
post: {
|
|
|
|
slug,
|
|
|
|
body: post.body,
|
|
|
|
title: post.title,
|
|
|
|
date: post.date,
|
|
|
|
caption: post.caption,
|
2023-07-03 13:28:41 -05:00
|
|
|
image: sanitySiteImage(post.image[0]),
|
2023-06-19 16:27:13 -05:00
|
|
|
designs,
|
|
|
|
},
|
|
|
|
// FIXME load the author separately
|
|
|
|
author: {
|
|
|
|
displayname: post.maker,
|
|
|
|
// slug: post.maker.slug,
|
|
|
|
// image: strapiImage(post.maker.picture, ['small']),
|
|
|
|
// ...(await mdxCompiler(post.maker.about)),
|
|
|
|
},
|
|
|
|
...(await serverSideTranslations(locale, namespaces)),
|
2023-07-03 13:28:41 -05:00
|
|
|
page: {
|
|
|
|
locale,
|
|
|
|
path: ['showcase', slug],
|
|
|
|
},
|
2023-06-19 16:27:13 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-04 13:28:46 -05:00
|
|
|
export const getStaticPaths = getSanityStaticPaths('showcase')
|
2023-06-19 16:27:13 -05:00
|
|
|
|
|
|
|
export default ShowcasePage
|