article page meta
This commit is contained in:
1 parent
33ee2d218e
commit
4ee2ec7d74
1 file changed
+10
@@ -6,6 +6,8 @@ import Article from '../../src/components/Article'
|
|||||||
import Html from '../../src/components/Html'
|
import Html from '../../src/components/Html'
|
||||||
import menuModel from '../../src/models/menu'
|
import menuModel from '../../src/models/menu'
|
||||||
import { buildMenu } from '../../src/lib/menu'
|
import { buildMenu } from '../../src/lib/menu'
|
||||||
|
import { Meta } from '../../src/components/Meta'
|
||||||
|
import { meta } from '../../src/lib/meta'
|
||||||
|
|
||||||
const Page = (props) => (
|
const Page = (props) => (
|
||||||
<App
|
<App
|
||||||
@@ -15,6 +17,7 @@ const Page = (props) => (
|
|||||||
>
|
>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{props.article.title}</title>
|
<title>{props.article.title}</title>
|
||||||
|
<Meta meta={props.meta} />
|
||||||
</Head>
|
</Head>
|
||||||
<div className={'content content_thin'}>
|
<div className={'content content_thin'}>
|
||||||
<Article
|
<Article
|
||||||
@@ -37,10 +40,17 @@ Page.getInitialProps = async (ctx) => {
|
|||||||
const apiUrl = `http://localhost:3000/api/articles/${id}`
|
const apiUrl = `http://localhost:3000/api/articles/${id}`
|
||||||
const res = await axios.get(apiUrl)
|
const res = await axios.get(apiUrl)
|
||||||
const article = res.data
|
const article = res.data
|
||||||
|
const image = article.preview.artifacts.fb
|
||||||
|
|
||||||
return {
|
return {
|
||||||
article,
|
article,
|
||||||
pageUrl,
|
pageUrl,
|
||||||
|
meta: meta({
|
||||||
|
title: article.title,
|
||||||
|
image: image.src,
|
||||||
|
imageWidth: image.width,
|
||||||
|
imageHeight: image.height,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user