1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 17:23:22 +01:00

change typekit again

This commit is contained in:
Matthias Kretschmann 2018-04-21 20:41:08 +02:00
parent 3d38f1d170
commit 6fec5a3c76
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 38 additions and 10 deletions

View File

@ -1,20 +1,22 @@
import React from 'react'
import React, { Fragment } from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import Typekit from './Typekit'
const Head = ({ meta }) => {
const { title, tagline, description, typekit } = meta
return (
<Helmet
defaultTitle={`${title.toLowerCase()} { ${tagline.toLowerCase()} }`}
titleTemplate={`%s // ${title.toLowerCase()} { ${tagline.toLowerCase()} }`}
>
<meta name="description" content={description} />
<link rel="stylesheet" href={`https://use.typekit.net/${typekit}.css`} />
<meta content="noindex,nofollow" name="robots" />
</Helmet>
<Fragment>
<Helmet
defaultTitle={`${title.toLowerCase()} { ${tagline.toLowerCase()} }`}
titleTemplate={`%s // ${title.toLowerCase()} { ${tagline.toLowerCase()} }`}
>
<meta name="description" content={description} />
<meta content="noindex,nofollow" name="robots" />
</Helmet>
<Typekit id={typekit} />
</Fragment>
)
}

View File

@ -0,0 +1,26 @@
import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
const TypekitScript = ({ id }) => (
<script>
{`
(function(d) {
var config = {
kitId: '${id}',
scriptTimeout: 3000,
async: true
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);
`}
</script>
)
const Typekit = props => <Helmet>{TypekitScript(props)}</Helmet>
export default Typekit
TypekitScript.propTypes = {
id: PropTypes.string.isRequired,
}