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 { ArticlePostData } from '@/types/data.types'
|
||||||
import { SEO } from '@/components/SEO'
|
import { SEO } from '@/components/SEO'
|
||||||
import { ArticleProvider } from '@/context/article.context'
|
import { ArticleProvider } from '@/context/article.context'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
type ArticleProps = {
|
type ArticleProps = {
|
||||||
data: ArticlePostData
|
data: ArticlePostData
|
||||||
errors: string | null
|
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>
|
if (errors) return <div>{errors}</div>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SEO title={data.article.title} description={data.article.summary} />
|
<SEO title={data.article.title} description={data.article.summary} />
|
||||||
|
@ -38,12 +46,15 @@ export const getStaticProps = async ({ params }: GetStaticPropsContext) => {
|
||||||
if (!slug) {
|
if (!slug) {
|
||||||
return {
|
return {
|
||||||
notFound: true,
|
notFound: true,
|
||||||
|
props: { why: 'no slug' },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: article, errors } = await api.getArticlePost(slug as string)
|
const { data: article, errors } = await api.getArticlePost(slug as string)
|
||||||
if (!article) {
|
if (!article) {
|
||||||
return {
|
return {
|
||||||
notFound: true,
|
notFound: true,
|
||||||
|
props: { why: 'no article' },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue