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' }, } }