handling build error
This commit is contained in:
parent
65992533c0
commit
5af0302828
|
@ -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 <div>{errors}</div>
|
||||
|
||||
return (
|
||||
<>
|
||||
<SEO title={data.article.title} description={data.article.summary} />
|
||||
|
@ -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' },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue