From 5af03028285cdf59833786e9f88e870479292d58 Mon Sep 17 00:00:00 2001 From: amirhouieh Date: Fri, 12 May 2023 18:56:04 +0200 Subject: [PATCH] handling build error --- src/pages/article/[slug].tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx index 93f05d5..68d4390 100644 --- a/src/pages/article/[slug].tsx +++ b/src/pages/article/[slug].tsx @@ -6,14 +6,22 @@ import api from '@/services/unbody.service' import { ArticlePostData } from '@/types/data.types' import { SEO } from '@/components/SEO' import { ArticleProvider } from '@/context/article.context' +import { useRouter } from 'next/router' type ArticleProps = { data: ArticlePostData errors: string | null + why?: string } -const ArticlePage = ({ data, errors }: ArticleProps) => { +const ArticlePage = ({ data, errors, why }: ArticleProps) => { + const { + query: { slug }, + } = useRouter() + console.log(typeof data, slug, why) + if (!data) return null if (errors) return
{errors}
+ return ( <> @@ -38,12 +46,15 @@ export const getStaticProps = async ({ params }: GetStaticPropsContext) => { if (!slug) { return { notFound: true, + props: { why: 'no slug' }, } } + const { data: article, errors } = await api.getArticlePost(slug as string) if (!article) { return { notFound: true, + props: { why: 'no article' }, } }