mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Example: Overwriting meta tag with react-helmet (#2942)
This commit is contained in:
parent
27f517d27d
commit
87d7ad2fc0
|
@ -31,7 +31,8 @@ export default class extends Document {
|
||||||
htmlAttributes={{lang: 'en'}}
|
htmlAttributes={{lang: 'en'}}
|
||||||
title='Hello next.js!'
|
title='Hello next.js!'
|
||||||
meta={[
|
meta={[
|
||||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||||
|
{ property: 'og:title', content: 'Hello next.js!' }
|
||||||
]}
|
]}
|
||||||
/>)
|
/>)
|
||||||
}
|
}
|
||||||
|
|
24
examples/with-react-helmet/pages/about.js
Normal file
24
examples/with-react-helmet/pages/about.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import React from 'react'
|
||||||
|
import Helmet from 'react-helmet'
|
||||||
|
|
||||||
|
export default class About extends React.Component {
|
||||||
|
static async getInitialProps ({ req }) {
|
||||||
|
if (req) {
|
||||||
|
Helmet.renderStatic()
|
||||||
|
}
|
||||||
|
return { title: 'About' }
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { title } = this.props
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Helmet
|
||||||
|
title={`${title} | Hello next.js!`}
|
||||||
|
meta={[{ property: 'og:title', content: title }]}
|
||||||
|
/>
|
||||||
|
About the World
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue