mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-04-29 05:49:11 +00:00
add robots meta tag handling
This commit is contained in:
parent
1a7b042351
commit
a98ba13f90
3 changed files with 14 additions and 10 deletions
|
@ -22,7 +22,7 @@ const MissingJS = styled.noscript`
|
||||||
`
|
`
|
||||||
|
|
||||||
class RoleypolyApp extends App {
|
class RoleypolyApp extends App {
|
||||||
static async getInitialProps ({ Component, ctx }: { Component: NextPage, ctx: {[x:string]: any}}) {
|
static async getInitialProps ({ Component, ctx, router }: { Component: NextPage, router: any, ctx: {[x:string]: any}}) {
|
||||||
// Fix for next/error rendering instead of our error page.
|
// Fix for next/error rendering instead of our error page.
|
||||||
// Who knows why this would ever happen.
|
// Who knows why this would ever happen.
|
||||||
if (Component.displayName === 'ErrorPage' || Component.constructor.name === 'ErrorPage') {
|
if (Component.displayName === 'ErrorPage' || Component.constructor.name === 'ErrorPage') {
|
||||||
|
@ -36,18 +36,19 @@ class RoleypolyApp extends App {
|
||||||
|
|
||||||
const user = await rpc.getCurrentUser()
|
const user = await rpc.getCurrentUser()
|
||||||
ctx.user = user
|
ctx.user = user
|
||||||
|
ctx.robots = 'INDEX, FOLLOW'
|
||||||
|
|
||||||
ctx.layout = {
|
ctx.layout = {
|
||||||
noBackground: false
|
noBackground: false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Component.getInitialProps) {
|
if (Component.getInitialProps) {
|
||||||
pageProps = await Component.getInitialProps(ctx, rpc)
|
pageProps = await Component.getInitialProps(ctx, rpc, router)
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log({ pageProps })
|
// console.log({ pageProps })
|
||||||
|
|
||||||
return { pageProps, user, layout: ctx.layout }
|
return { pageProps, user, layout: ctx.layout, robots: ctx.robots }
|
||||||
}
|
}
|
||||||
|
|
||||||
catchFOUC () {
|
catchFOUC () {
|
||||||
|
@ -57,7 +58,7 @@ class RoleypolyApp extends App {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { Component, pageProps, router, user, layout } = this.props
|
const { Component, pageProps, router, user, layout, robots } = this.props
|
||||||
// Fix for next/error rendering instead of our error page.
|
// Fix for next/error rendering instead of our error page.
|
||||||
// Who knows why this would ever happen.
|
// Who knows why this would ever happen.
|
||||||
const ErrorCaughtComponent = (Component.displayName === 'ErrorPage' || Component.constructor.name === 'ErrorPage') ? ErrorP : Component
|
const ErrorCaughtComponent = (Component.displayName === 'ErrorPage' || Component.constructor.name === 'ErrorPage') ? ErrorP : Component
|
||||||
|
@ -71,6 +72,7 @@ class RoleypolyApp extends App {
|
||||||
<title key='title'>Roleypoly</title>
|
<title key='title'>Roleypoly</title>
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
||||||
<link rel='icon' href='/static/favicon.png' />
|
<link rel='icon' href='/static/favicon.png' />
|
||||||
|
<meta key='robots' name='robots' content={robots} />
|
||||||
<script key='typekit' dangerouslySetInnerHTML={{ __html: `
|
<script key='typekit' dangerouslySetInnerHTML={{ __html: `
|
||||||
(function(d) {
|
(function(d) {
|
||||||
var config = {
|
var config = {
|
||||||
|
|
|
@ -55,8 +55,9 @@ const Code = styled.h1`
|
||||||
`
|
`
|
||||||
|
|
||||||
export default class CustomErrorPage extends React.Component {
|
export default class CustomErrorPage extends React.Component {
|
||||||
static getInitialProps ({ res, err }) {
|
static getInitialProps ({ res, err, robots }) {
|
||||||
const statusCode = res ? res.statusCode : err ? err.statusCode : null
|
const statusCode = res ? res.statusCode : err ? err.statusCode : null
|
||||||
|
robots = 'NOINDEX, NOFOLLOW'
|
||||||
return { statusCode }
|
return { statusCode }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
ui/types.js
11
ui/types.js
|
@ -1,8 +1,9 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
import type { ServerSlug as BackendServerSlug } from '../services/presentation'
|
||||||
|
import type Router from 'next/router'
|
||||||
|
|
||||||
export type PageProps = {
|
export type PageProps = {
|
||||||
router: {
|
router: Router
|
||||||
query: {
|
|
||||||
[key: string]: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ServerSlug = BackendServerSlug
|
||||||
|
|
Loading…
Add table
Reference in a new issue