1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-06-30 05:31:44 +02:00

prevent search engines on unallowed hosts

This commit is contained in:
Matthias Kretschmann 2018-12-09 15:14:31 +01:00
parent d97fa8bb2e
commit 639127af9e
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 19 additions and 11 deletions

View File

@ -1,11 +1,8 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import Helmet from 'react-helmet'
import styles from './HostnameCheck.module.scss' import styles from './HostnameCheck.module.scss'
const allowedHosts = [ const allowedHosts = ['matthiaskretschmann.com', 'beta.matthiaskretschmann.com']
'matthiaskretschmann.com',
'beta.matthiaskretschmann.com',
'localhost'
]
export default class HostnameInfo extends PureComponent { export default class HostnameInfo extends PureComponent {
checkAllowedHost = () => { checkAllowedHost = () => {
@ -15,6 +12,7 @@ export default class HostnameInfo extends PureComponent {
} }
state = { state = {
// default to true so SSR builds never show the banner
isAllowedHost: true isAllowedHost: true
} }
@ -24,16 +22,19 @@ export default class HostnameInfo extends PureComponent {
} }
render() { render() {
// return nothing if we're on an allowed host
if (this.state.isAllowedHost) return null if (this.state.isAllowedHost) return null
return ( return (
<> <>
<Helmet>
<meta name="robots" content="noindex,nofollow" />
</Helmet>
<aside className={styles.hostnameInfo}> <aside className={styles.hostnameInfo}>
Hi there 👋. Please note that only the code and documentation of this <p>{`Hi there 👋. Please note that only the code and documentation of this
site are MIT licensed. But my logo and the combination of typography, site are open source. But my logo and the combination of typography,
colors, and layout making up my brand identity are not. Likewise, if colors, and layout making up my brand identity are not. Don't just
you know how to remove this banner you also should be able to remove clone, do a remix.`}</p>
my Typekit code and Analytics code from your published site.
</aside> </aside>
</> </>
) )

View File

@ -4,7 +4,7 @@
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 99; z-index: 99;
padding: $spacer / 2 $spacer; padding: $spacer / 3;
font-size: $font-size-small; font-size: $font-size-small;
font-weight: bold; font-weight: bold;
background: rgba($brand-light, .8); background: rgba($brand-light, .8);
@ -12,4 +12,11 @@
:global(.dark) & { :global(.dark) & {
background: rgba($body-background-color--dark, .8); background: rgba($body-background-color--dark, .8);
} }
p {
margin: auto;
margin-bottom: 0;
max-width: $screen-lg;
text-align: center;
}
} }