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