2018-12-08 20:27:45 +01:00
|
|
|
import React, { PureComponent } from 'react'
|
2019-04-14 16:58:20 +02:00
|
|
|
import PropTypes from 'prop-types'
|
2020-04-11 23:40:25 +02:00
|
|
|
import { Helmet } from 'react-helmet'
|
2021-03-12 23:47:28 +01:00
|
|
|
import { hostnameInfo } from './HostnameCheck.module.css'
|
2018-12-08 20:27:45 +01:00
|
|
|
|
2019-04-14 16:58:20 +02:00
|
|
|
export default class HostnameCheck extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
allowedHosts: PropTypes.array.isRequired
|
|
|
|
}
|
2018-12-08 20:27:45 +01:00
|
|
|
|
|
|
|
checkAllowedHost = () => {
|
|
|
|
if (typeof window !== 'undefined' && window.location) {
|
2019-04-14 16:58:20 +02:00
|
|
|
return this.props.allowedHosts.includes(window.location.hostname)
|
2018-12-08 20:27:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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>
|
2021-03-12 23:47:28 +01:00
|
|
|
<aside className={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>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|