1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-next-seo/pages/_app.js
Gary Meehan b8c9a1b574 Add next-seo example (#6088)
This PR adds a basic example using [next-seo](https://www.npmjs.com/package/next-seo).
2019-01-19 13:07:13 +01:00

33 lines
883 B
JavaScript

/**
* Using a custom _app.js with next-seo you can set default SEO
* that will apply to every page. Full info on how the default works
* can be found here: https://github.com/garmeeh/next-seo#default-seo-configuration
*/
import App, { Container } from 'next/app'
import React from 'react'
import NextSeo from 'next-seo'
import SEO from '../next-seo.config'
export default class MyApp extends App {
static async getInitialProps ({ Component, ctx }) {
let pageProps = {}
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}
return { pageProps }
}
render () {
const { Component, pageProps } = this.props
return (
<Container>
{/* Here we call NextSeo and pass our default configuration to it */}
<NextSeo config={SEO} />
<Component {...pageProps} />
</Container>
)
}
}