wildcard page meta updated
This commit is contained in:
1 parent
76e7a7e9bb
commit
e7de465e2c
1 file changed
+11
-14
+11
-14
@@ -3,8 +3,8 @@ import { App } from 'src/components/App'
|
|||||||
import { tail } from 'lodash'
|
import { tail } from 'lodash'
|
||||||
import { Page } from 'src/components/Page'
|
import { Page } from 'src/components/Page'
|
||||||
import { Meta } from 'src/components/Meta'
|
import { Meta } from 'src/components/Meta'
|
||||||
import { meta } from 'src/lib/meta'
|
import { MetaBuilder } from 'src/lib/meta'
|
||||||
import { createApiUrl, requestGet, wrapInitialProps, IResponseItems } from 'src/next-lib'
|
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
||||||
import { NextPage } from 'next'
|
import { NextPage } from 'next'
|
||||||
import { IBreadcumbsPart, IMeta, IPage } from 'src/types'
|
import { IBreadcumbsPart, IMeta, IPage } from 'src/types'
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@ function array<T>(value: T | T[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
page: any
|
|
||||||
title: string
|
title: string
|
||||||
content: string
|
content: string
|
||||||
breadcrumb: IBreadcumbsPart[]
|
breadcrumb: IBreadcumbsPart[]
|
||||||
@@ -32,7 +31,7 @@ const Index: NextPage<Props> = props => (
|
|||||||
>
|
>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{props.title}</title>
|
<title>{props.title}</title>
|
||||||
{/* <Meta meta={props.meta} /> */}
|
<Meta meta={props.meta} />
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<Page
|
<Page
|
||||||
@@ -54,29 +53,27 @@ export const unstable_getStaticProps = async (ctx: any) => {
|
|||||||
if (!page) {
|
if (!page) {
|
||||||
throw new Error(`Not found: ${slug}`)
|
throw new Error(`Not found: ${slug}`)
|
||||||
}
|
}
|
||||||
const image = page.preview ? page.preview.artifacts.fb : {}
|
const description = page.description ?? ''
|
||||||
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())
|
||||||
|
.setImage(page.preview)
|
||||||
|
.setTitle(page.title)
|
||||||
|
.setDescription(description)
|
||||||
|
.build()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
page,
|
|
||||||
content: page.data,
|
content: page.data,
|
||||||
title: page.title,
|
title: page.title,
|
||||||
meta: meta({
|
meta,
|
||||||
title: page.title,
|
|
||||||
image: image.src,
|
|
||||||
imageWidth: image.width,
|
|
||||||
imageHeight: image.height,
|
|
||||||
}),
|
|
||||||
breadcrumb,
|
breadcrumb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const unstable_getStaticPaths = async () => {
|
export const unstable_getStaticPaths = async () => {
|
||||||
console.log('call all unstable_getStaticPaths')
|
|
||||||
|
|
||||||
const urls = await requestGet<IResponseItems<string>>(createApiUrl(`/api/pages/urls`), null)
|
const urls = await requestGet<IResponseItems<string>>(createApiUrl(`/api/pages/urls`), null)
|
||||||
if (!urls) {
|
if (!urls) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
Reference in new issue
Block a user