diff --git a/website/gatsby-config.js b/website/gatsby-config.js index d0af80d8..fa998383 100644 --- a/website/gatsby-config.js +++ b/website/gatsby-config.js @@ -38,8 +38,6 @@ module.exports = { name: 'content', }, }, - 'gatsby-transformer-yaml', - 'gatsby-transformer-json', { resolve: 'gatsby-source-filesystem', options: { @@ -62,6 +60,8 @@ module.exports = { ] }, }, + 'gatsby-transformer-yaml', + 'gatsby-transformer-json', 'gatsby-plugin-postcss', 'gatsby-plugin-react-helmet', 'gatsby-plugin-catch-links', diff --git a/website/src/components/github-button.js b/website/src/components/github-button.js new file mode 100644 index 00000000..d00b0e47 --- /dev/null +++ b/website/src/components/github-button.js @@ -0,0 +1,32 @@ +import React, { PureComponent } from 'react'; + +class GitHubStarButton extends PureComponent { + async componentDidMount() { + const gitHubButtonModule = await import('github-buttons/dist/react'); + + this.GitHubButton = gitHubButtonModule.default; + + this.forceUpdate(); + } + + render() { + const GitHubButton = this.GitHubButton; + + if (!GitHubButton) { + return null; + } + + return ( + + Star + + ); + } +} + +export default GitHubStarButton; diff --git a/website/src/components/header.js b/website/src/components/header.js index 03e4c9a0..2482d7fb 100644 --- a/website/src/components/header.js +++ b/website/src/components/header.js @@ -4,6 +4,7 @@ import classnames from 'classnames'; import { Location } from '@reach/router'; import DocSearch from './docsearch'; +import GitHubButton from './github-button'; import logo from '../img/netlify-cms-logo.svg'; @@ -17,9 +18,6 @@ class Header extends Component { async componentDidMount() { // TODO: use raf to throttle events window.addEventListener('scroll', this.handleScroll); - const gitHubButtonModule = await import('github-buttons/dist/react'); - this.GitHubButton = gitHubButtonModule.default; - this.forceUpdate(); } componentWillUnmount() { @@ -38,7 +36,6 @@ class Header extends Component { render() { const { scrolled } = this.state; - const GitHubButton = this.GitHubButton; return ( @@ -76,16 +73,7 @@ class Header extends Component { Blog - {GitHubButton && ( - - Star - - )} +