wildcard page meta stability improved

This commit is contained in:
tmshv committed 2020-02-25 02:28:31 +03:00
1 parent 488ea6ec06
commit b62a0588ae
1 file changed
+6 -5
+6 -5
View File
@@ -18,7 +18,7 @@ type Props = {
title: string title: string
content: string content: string
breadcrumb: IBreadcumbsPart[] breadcrumb: IBreadcumbsPart[]
meta: IMeta meta?: IMeta
} }
const Index: NextPage<Props> = props => ( const Index: NextPage<Props> = props => (
@@ -31,7 +31,9 @@ const Index: NextPage<Props> = props => (
> >
<Head> <Head>
<title>{props.title}</title> <title>{props.title}</title>
<Meta meta={props.meta} /> {!props.meta ? null : (
<Meta meta={props.meta} />
)}
</Head> </Head>
<Page <Page
@@ -53,10 +55,9 @@ export const unstable_getStaticProps = async (ctx: any) => {
if (!page) { if (!page) {
throw new Error(`Not found: ${slug}`) throw new Error(`Not found: ${slug}`)
} }
const description = page.description ?? null const description = page.description ?? undefined
const breadcrumbSize = page.breadcrumb?.length ?? 0 const breadcrumbSize = page?.breadcrumb?.length ?? 0
const breadcrumb = breadcrumbSize < 2 ? null : page.breadcrumb const breadcrumb = breadcrumbSize < 2 ? null : page.breadcrumb
const meta = (new MetaBuilder()) const meta = (new MetaBuilder())
.setImage(page.preview) .setImage(page.preview)
.setTitle(page.title) .setTitle(page.title)