2018-12-08 20:27:45 +01:00
|
|
|
import React, { PureComponent } from 'react'
|
2018-12-09 15:14:31 +01:00
|
|
|
import Helmet from 'react-helmet'
|
2018-12-08 20:27:45 +01:00
|
|
|
import styles from './HostnameCheck.module.scss'
|
|
|
|
|
2018-12-12 18:28:09 +01:00
|
|
|
const allowedHosts = [
|
|
|
|
'matthiaskretschmann.com',
|
|
|
|
'beta.matthiaskretschmann.com',
|
|
|
|
'localhost'
|
|
|
|
]
|
2018-12-08 20:27:45 +01:00
|
|
|
|
|
|
|
export default class HostnameInfo extends PureComponent {
|
|
|
|
checkAllowedHost = () => {
|
|
|
|
if (typeof window !== 'undefined' && window.location) {
|
|
|
|
return allowedHosts.includes(window.location.hostname)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
state = {
|
2018-12-09 15:14:31 +01:00
|
|
|
// default to true so SSR builds never show the banner
|
2018-12-08 20:27:45 +01:00
|
|
|
isAllowedHost: true
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
const isAllowedHost = this.checkAllowedHost()
|
|
|
|
this.setState({ isAllowedHost })
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-12-09 15:14:31 +01:00
|
|
|
// return nothing if we're on an allowed host
|
2018-12-08 20:27:45 +01:00
|
|
|
if (this.state.isAllowedHost) return null
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2018-12-09 15:14:31 +01:00
|
|
|
<Helmet>
|
|
|
|
<meta name="robots" content="noindex,nofollow" />
|
|
|
|
</Helmet>
|
2018-12-08 20:27:45 +01:00
|
|
|
<aside className={styles.hostnameInfo}>
|
2018-12-09 15:14:31 +01:00
|
|
|
<p>{`Hi there 👋. Please note that only the code and documentation of this
|
|
|
|
site are open source. But my logo and the combination of typography,
|
|
|
|
colors, and layout making up my brand identity are not. Don't just
|
|
|
|
clone, do a remix.`}</p>
|
2018-12-08 20:27:45 +01:00
|
|
|
</aside>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|