|
| 1 | +import React from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
| 3 | +import config from '../config'; |
| 4 | +import Loader from './components/images/loader.svg'; |
| 5 | + |
| 6 | +export default class HTML extends React.Component { |
| 7 | + |
| 8 | + render() { |
| 9 | + return ( |
| 10 | + <html {...this.props.htmlAttributes} lang="en"> |
| 11 | + <head> |
| 12 | + <meta charSet="utf-8"/> |
| 13 | + <meta httpEquiv="x-ua-compatible" content="ie=edge"/> |
| 14 | + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/> |
| 15 | + {config.siteMetadata.ogImage ? ( |
| 16 | + <meta property="og:image" content={config.siteMetadata.ogImage}/> |
| 17 | + ) : null} |
| 18 | + <meta property="twitter:card" content="summary_large_image"/> |
| 19 | + {config.siteMetadata.ogImage ? ( |
| 20 | + <meta property="twitter:image" content={config.siteMetadata.ogImage}/> |
| 21 | + ) : null} |
| 22 | + {config.siteMetadata.favicon ? ( |
| 23 | + <link rel="shortcut icon" type="image/svg" href={config.siteMetadata.favicon}/> |
| 24 | + ) : null} |
| 25 | + <noscript key="noscript"></noscript> |
| 26 | + {this.props.headComponents} |
| 27 | + </head> |
| 28 | + <body {...this.props.bodyAttributes}> |
| 29 | + {this.props.preBodyComponents} |
| 30 | + <div |
| 31 | + key={`loader`} |
| 32 | + id="___loader" |
| 33 | + style={{ |
| 34 | + alignItems: "center", |
| 35 | + backgroundColor: "#FFFFFF", |
| 36 | + display: "flex", |
| 37 | + justifyContent: "center", |
| 38 | + position: "absolute", |
| 39 | + left: 0, |
| 40 | + top: 0, |
| 41 | + right: 0, |
| 42 | + bottom: 0, |
| 43 | + zIndex: 100, |
| 44 | + }} |
| 45 | + > |
| 46 | + <img |
| 47 | + src={Loader} |
| 48 | + alt="loading spinner" |
| 49 | + width="150" |
| 50 | + height="150" |
| 51 | + /> |
| 52 | + </div> |
| 53 | + <div key={`body`} id="___gatsby" dangerouslySetInnerHTML={{__html: this.props.body}}/> |
| 54 | + {this.props.postBodyComponents} |
| 55 | + <script |
| 56 | + defer |
| 57 | + dangerouslySetInnerHTML={{ |
| 58 | + __html: ` |
| 59 | + function navBarClose() { |
| 60 | + document.getElementById("navbar").classList.toggle("responsive"); |
| 61 | + } |
| 62 | + document.addEventListener('click',function(e){ |
| 63 | + if(e.target && e.target.tagName.toLowerCase() === 'a'){ |
| 64 | + navBarClose(); |
| 65 | + } |
| 66 | + }); |
| 67 | + `, |
| 68 | + }} |
| 69 | + /> |
| 70 | + </body> |
| 71 | + </html> |
| 72 | + ); |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +HTML.propTypes = { |
| 77 | + htmlAttributes: PropTypes.object, |
| 78 | + headComponents: PropTypes.array, |
| 79 | + bodyAttributes: PropTypes.object, |
| 80 | + preBodyComponents: PropTypes.array, |
| 81 | + body: PropTypes.string, |
| 82 | + postBodyComponents: PropTypes.array, |
| 83 | +}; |
0 commit comments