throw if slug is missing

This commit is contained in:
Daniel Cruz committed 2023-07-08 19:22:57 -06:00
1 parent 7fc3cbd23d
commit c6f426402d
1 file changed
+5 -1
+5 -1
View File
@@ -73,7 +73,11 @@ export async function getStaticPaths() {
}
export const getStaticProps: GetStaticProps<BlogPostPageProps, Params> = async ({ params }) => {
const filePath = `${params?.slug}`
if (params?.slug === undefined) {
throw new Error('Missing slug for pages/blog/[slug].tsx')
}
const filePath = `${params.slug}`
const postContent = await getPostdata(filePath, '_blog')
const { data, content } = matter(postContent) as unknown as MatterReturn