From 87d7ad2fc0ba887b1e51b7caaf893f532a8c2ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Vin=C3=ADcius=20Oliveira=20Sena?= Date: Tue, 12 Sep 2017 09:55:40 -0300 Subject: [PATCH] Example: Overwriting meta tag with react-helmet (#2942) --- examples/with-react-helmet/pages/_document.js | 3 ++- examples/with-react-helmet/pages/about.js | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 examples/with-react-helmet/pages/about.js diff --git a/examples/with-react-helmet/pages/_document.js b/examples/with-react-helmet/pages/_document.js index 62a5354a..2403a6b4 100644 --- a/examples/with-react-helmet/pages/_document.js +++ b/examples/with-react-helmet/pages/_document.js @@ -31,7 +31,8 @@ export default class extends Document { htmlAttributes={{lang: 'en'}} title='Hello next.js!' 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!' } ]} />) } diff --git a/examples/with-react-helmet/pages/about.js b/examples/with-react-helmet/pages/about.js new file mode 100644 index 00000000..79cf65ab --- /dev/null +++ b/examples/with-react-helmet/pages/about.js @@ -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 ( +
+ + About the World +
+ ) + } +}