docs: migrate website to Gatsby v2 (#1623)

* website: initial conversion to gatsby v2

* fix unexpected history use warning

* use commonjs only to fix gatsby error

* fix gatsby import error with sidecar

* remove unused postcss-colour-functions

* remove unused prop

* lowercase layout filename import to match actual file

* chore(lint): format code
This commit is contained in:
Zeb Pykosz 2018-08-23 17:58:38 -04:00 committed by Caleb
parent a1677b0e24
commit f58db5fb08
17 changed files with 4084 additions and 4662 deletions

View File

@ -1,4 +0,0 @@
{
"presets": ["react", "es2015", "stage-1"],
"plugins": ["add-module-exports"]
}

View File

@ -1,5 +0,0 @@
{
"globals": {
"graphql": true
}
}

View File

@ -1,7 +1,6 @@
import SmoothScroll from 'smooth-scroll';
// Make scroll behavior of internal links smooth // Make scroll behavior of internal links smooth
exports.onClientEntry = () => { exports.onClientEntry = () => {
const SmoothScroll = require('smooth-scroll');
new SmoothScroll('a[href*="#"]', { new SmoothScroll('a[href*="#"]', {
offset() { offset() {
return document.querySelector('#header').offsetHeight; return document.querySelector('#header').offsetHeight;

View File

@ -1,23 +1,5 @@
const pkg = require('./package.json'); const pkg = require('./package.json');
const neatgrid = require('postcss-neat');
const nestedcss = require('postcss-nested');
const colorfunctions = require('postcss-colour-functions');
const hdBackgrounds = require('postcss-at2x');
const cssextend = require('postcss-simple-extend');
const cssvars = require('postcss-simple-vars-async');
const styleVariables = require('./src/theme');
const postCssPlugins = [
neatgrid(),
nestedcss(),
colorfunctions(),
hdBackgrounds(),
cssextend(),
cssvars({ variables: styleVariables }),
];
module.exports = { module.exports = {
siteMetadata: { siteMetadata: {
title: 'Netlify CMS | Open-Source Content Management System', title: 'Netlify CMS | Open-Source Content Management System',
@ -71,14 +53,8 @@ module.exports = {
] ]
}, },
}, },
{ 'gatsby-plugin-postcss',
resolve: 'gatsby-plugin-postcss-sass',
options: {
postCssPlugins,
},
},
'gatsby-plugin-react-helmet', 'gatsby-plugin-react-helmet',
'gatsby-plugin-react-next',
'gatsby-plugin-catch-links', 'gatsby-plugin-catch-links',
{ {
resolve: `gatsby-plugin-manifest`, resolve: `gatsby-plugin-manifest`,

View File

@ -15,32 +15,34 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"classnames": "^2.2.5", "classnames": "^2.2.5",
"eslint": "^3.1.1", "gatsby": "next",
"eslint-plugin-import": "^1.11.1", "gatsby-plugin-catch-links": "next",
"gatsby": "^1.9.270", "gatsby-plugin-manifest": "next",
"gatsby-plugin-catch-links": "^1.0.22", "gatsby-plugin-postcss": "^1.0.0",
"gatsby-plugin-manifest": "^1.0.21", "gatsby-plugin-react-helmet": "next",
"gatsby-plugin-postcss-sass": "^1.0.20", "gatsby-remark-autolink-headers": "next",
"gatsby-plugin-react-helmet": "^2.0.11", "gatsby-remark-prismjs": "next",
"gatsby-plugin-react-next": "^1.0.11", "gatsby-source-filesystem": "next",
"gatsby-remark-autolink-headers": "^1.4.18", "gatsby-transformer-json": "next",
"gatsby-remark-prismjs": "^2.0.2", "gatsby-transformer-remark": "next",
"gatsby-source-filesystem": "^1.5.35", "gatsby-transformer-yaml": "next",
"gatsby-transformer-json": "^1.0.17",
"gatsby-transformer-remark": "^1.7.42",
"gatsby-transformer-yaml": "^1.5.16",
"postcss-at2x": "^2.0.0", "postcss-at2x": "^2.0.0",
"postcss-colour-functions": "^1.5.1",
"postcss-cssnext": "^2.7.0", "postcss-cssnext": "^2.7.0",
"postcss-neat": "^2.5.2", "postcss-neat": "^2.5.2",
"postcss-nested": "^1.0.0", "postcss-nested": "^1.0.0",
"postcss-simple-extend": "^1.0.0", "postcss-simple-extend": "^1.0.0",
"postcss-simple-vars-async": "^1.2.1", "postcss-simple-vars-async": "^1.2.1",
"prismjs": "^1.14.0", "prismjs": "^1.14.0",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-helmet": "^5.2.0", "react-helmet": "^5.2.0",
"react-markdown": "^3.3.2", "react-markdown": "^3.3.2",
"react-sidecar": "^0.1.1", "react-sidecar": "^0.1.1",
"smooth-scroll": "^14.2.0" "smooth-scroll": "^14.2.0"
}, },
"devDependencies": {
"eslint": "^3.1.1",
"eslint-plugin-import": "^1.11.1"
},
"private": true "private": true
} }

19
website/postcss.config.js Normal file
View File

@ -0,0 +1,19 @@
const neatgrid = require('postcss-neat');
const nestedcss = require('postcss-nested');
// const colorfunctions = require('postcss-colour-functions');
const hdBackgrounds = require('postcss-at2x');
const cssextend = require('postcss-simple-extend');
const cssvars = require('postcss-simple-vars-async');
const styleVariables = require('./src/theme');
module.exports = () => ({
plugins: [
neatgrid(),
nestedcss(),
// colorfunctions(),
hdBackgrounds(),
cssextend(),
cssvars({ variables: styleVariables }),
],
});

View File

@ -1,6 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import Link from 'gatsby-link'; import Link from 'gatsby-link';
import classnames from 'classnames'; import classnames from 'classnames';
import { Location } from '@reach/router';
import DocSearch from './docsearch'; import DocSearch from './docsearch';
@ -33,56 +34,61 @@ class Header extends Component {
}; };
render() { render() {
const { location } = this.props;
const { scrolled } = this.state; const { scrolled } = this.state;
const isDocs = location.pathname.indexOf('docs') !== -1;
const isBlog = location.pathname.indexOf('blog') !== -1;
return ( return (
<header <Location>
id="header" {({ location }) => {
className={classnames({ const isDocs = location.pathname.indexOf('docs') !== -1;
docs: isDocs, const isBlog = location.pathname.indexOf('blog') !== -1;
blog: isBlog,
scrolled, return (
})} <header
> id="header"
<div className="contained"> className={classnames({
<div className="logo-container"> docs: isDocs,
<Link to="/" className="logo"> blog: isBlog,
<img src={logo} /> scrolled,
</Link> })}
{isDocs && <DocSearch />} >
</div> <div className="contained">
<div className="nav-container"> <div className="logo-container">
<Link className="nav-link docs-link" to="/docs/intro"> <Link to="/" className="logo">
Docs <img src={logo} />
</Link> </Link>
<Link className="nav-link contributing-link" to="/docs/contributor-guide"> {isDocs && <DocSearch />}
Contributing </div>
</Link> <div className="nav-container">
<Link className="nav-link" to="/community"> <Link className="nav-link docs-link" to="/docs/intro">
Community Docs
</Link> </Link>
<Link className="nav-link" to="/blog"> <Link className="nav-link contributing-link" to="/docs/contributor-guide">
Blog Contributing
</Link> </Link>
<span className="gh-button"> <Link className="nav-link" to="/community">
<a Community
id="ghstars" </Link>
className="github-button" <Link className="nav-link" to="/blog">
href="https://github.com/netlify/netlify-cms" Blog
data-icon="octicon-star" </Link>
data-show-count="true" <span className="gh-button">
aria-label="Star netlify/netlify-cms on GitHub" <a
> id="ghstars"
Star className="github-button"
</a> href="https://github.com/netlify/netlify-cms"
</span> data-icon="octicon-star"
</div> data-show-count="true"
</div> aria-label="Star netlify/netlify-cms on GitHub"
</header> >
Star
</a>
</span>
</div>
</div>
</header>
);
}}
</Location>
); );
} }
} }

View File

@ -0,0 +1,77 @@
import React, { Fragment } from 'react';
import Helmet from 'react-helmet';
import classnames from 'classnames';
import { graphql, StaticQuery } from 'gatsby';
import Header from './header';
import Footer from './footer';
import '../css/imports/base.css';
import '../css/imports/utilities.css';
import '../css/imports/gitter.css';
const Layout = ({ children }) => {
return (
<StaticQuery
query={graphql`
query layoutQuery {
site {
siteMetadata {
title
description
}
}
footer: file(relativePath: { regex: "/global/" }) {
childDataYaml {
footer {
buttons {
url
name
}
}
}
}
notifs: file(relativePath: { regex: "/notifications/" }) {
childDataYaml {
notifications {
published
loud
message
url
}
}
}
}
`}
>
{data => {
const { title, description } = data.site.siteMetadata;
const notifs = data.notifs.childDataYaml.notifications.filter(notif => notif.published);
return (
<Fragment>
<Helmet defaultTitle={title} titleTemplate={`%s | ${title}`}>
<meta name="description" content={description} />
</Helmet>
{notifs.map((node, i) => (
<a
key={i}
href={node.url}
className={classnames('notification', {
'notification-loud': node.loud,
})}
>
{node.message}
</a>
))}
<Header notifications={notifs} />
{children}
<Footer buttons={data.footer.childDataYaml.footer.buttons} />
</Fragment>
);
}}
</StaticQuery>
);
};
export default Layout;

View File

@ -33,7 +33,7 @@ class Widgets extends Component {
currentWidget: target, currentWidget: target,
}, },
() => { () => {
history.pushState(null, null, `#${target}`); window.history.pushState(null, null, `#${target}`);
}, },
); );
}; };

View File

@ -1,22 +1,10 @@
import React from 'react'; import React from 'react';
import Gitter from 'react-sidecar'; // gatsby throws some error when importing just react-sidecar.
// Maybe because jsx file ext?
import Gitter from 'react-sidecar/dist-modules/index.js';
let stylesStr; class HTML extends React.Component {
if (process.env.NODE_ENV === `production`) {
try {
stylesStr = require('!raw-loader!../public/styles.css');
} catch (e) {
console.log(e);
}
}
module.exports = class HTML extends React.Component {
render() { render() {
let css;
if (process.env.NODE_ENV === 'production') {
css = <style id="gatsby-inlined-css" dangerouslySetInnerHTML={{ __html: stylesStr }} />;
}
return ( return (
<html {...this.props.htmlAttributes}> <html {...this.props.htmlAttributes}>
<head> <head>
@ -30,7 +18,6 @@ module.exports = class HTML extends React.Component {
<meta name="apple-mobile-web-app-title" content="NetlifyCMS" /> <meta name="apple-mobile-web-app-title" content="NetlifyCMS" />
<meta name="application-name" content="NetlifyCMS" /> <meta name="application-name" content="NetlifyCMS" />
{this.props.headComponents} {this.props.headComponents}
{css}
<link <link
rel="stylesheet" rel="stylesheet"
href="https://unpkg.com/docsearch.js@2.5.2/dist/cdn/docsearch.min.css" href="https://unpkg.com/docsearch.js@2.5.2/dist/cdn/docsearch.min.css"
@ -47,4 +34,6 @@ module.exports = class HTML extends React.Component {
</html> </html>
); );
} }
}; }
export default HTML;

View File

@ -1,66 +0,0 @@
import React, { Fragment } from 'react';
import Helmet from 'react-helmet';
import classnames from 'classnames';
import Header from '../components/header';
import Footer from '../components/footer';
import '../css/imports/base.css';
import '../css/imports/utilities.css';
import '../css/imports/gitter.css';
const Layout = ({ data, location, children }) => {
const { title, description } = data.site.siteMetadata;
const notifs = data.notifs.notifications.filter(notif => notif.published);
return (
<Fragment>
<Helmet defaultTitle={title} titleTemplate={`%s | ${title}`}>
<meta name="description" content={description} />
</Helmet>
{notifs.map((node, i) => (
<a
key={i}
href={node.url}
className={classnames('notification', {
'notification-loud': node.loud,
})}
>
{node.message}
</a>
))}
<Header location={location} notifications={notifs} />
{children()}
<Footer buttons={data.dataYaml.footer.buttons} />
</Fragment>
);
};
export const pageQuery = graphql`
query layoutQuery {
site {
siteMetadata {
title
description
}
}
dataYaml(id: { regex: "/global/" }) {
footer {
buttons {
url
name
}
}
}
notifs: dataYaml(id: { regex: "/notifications/" }) {
notifications {
published
loud
message
url
}
}
}
`;
export default Layout;

View File

@ -1,31 +1,35 @@
import React from 'react'; import React from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import Link from 'gatsby-link'; import { Link, graphql } from 'gatsby';
import Layout from '../components/layout';
const Blog = ({ data }) => ( const Blog = ({ data }) => (
<div className="blog page"> <Layout>
<Helmet> <div className="blog page">
<title>Blog</title> <Helmet>
<meta name="description" content="Recent news and updates about Netlify CMS." /> <title>Blog</title>
</Helmet> <meta name="description" content="Recent news and updates about Netlify CMS." />
<div className="container"> </Helmet>
<h1>Netlify CMS Blog</h1> <div className="container">
{data.allMarkdownRemark.edges.map(({ node }) => ( <h1>Netlify CMS Blog</h1>
<article className="blog-list-item" key={node.id}> {data.allMarkdownRemark.edges.map(({ node }) => (
<h2> <article className="blog-list-item" key={node.id}>
<Link to={node.fields.slug} className="article"> <h2>
{node.frontmatter.title} <Link to={node.fields.slug} className="article">
</Link> {node.frontmatter.title}
</h2> </Link>
<p className="meta-info"> </h2>
by {node.frontmatter.author} on {node.frontmatter.date} <p className="meta-info">
</p> by {node.frontmatter.author} on {node.frontmatter.date}
<p>{node.frontmatter.description}</p> </p>
</article> <p>{node.frontmatter.description}</p>
))} </article>
{/* TODO: pagination */} ))}
{/* TODO: pagination */}
</div>
</div> </div>
</div> </Layout>
); );
export default Blog; export default Blog;

View File

@ -1,7 +1,9 @@
import React from 'react'; import React from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import Markdown from 'react-markdown'; import Markdown from 'react-markdown';
import { graphql } from 'gatsby';
import Layout from '../components/layout';
import EventWidget from '../components/event-widget'; import EventWidget from '../components/event-widget';
import Markdownify from '../components/markdownify'; import Markdownify from '../components/markdownify';
@ -19,57 +21,59 @@ const CommunityPage = ({ data }) => {
} = data.markdownRemark.frontmatter; } = data.markdownRemark.frontmatter;
return ( return (
<div className="community page"> <Layout>
<Helmet title={title} /> <div className="community page">
<section className="community hero"> <Helmet title={title} />
<div className="contained"> <section className="community hero">
<div className="hero-copy"> <div className="contained">
<h1 className="headline"> <div className="hero-copy">
<Markdownify source={headline} /> <h1 className="headline">
</h1> <Markdownify source={headline} />
<h2 className="subhead"> </h1>
<Markdownify source={subhead} /> <h2 className="subhead">
</h2> <Markdownify source={subhead} />
<h3 className="ctas"> </h2>
<ul> <h3 className="ctas">
<li> <ul>
<Markdownify source={primarycta} /> <li>
</li> <Markdownify source={primarycta} />
</ul> </li>
</h3> </ul>
</div> </h3>
</div>
<div className="calendar-cta"> <div className="calendar-cta">
<h2>{upcomingevent.hook}</h2> <h2>{upcomingevent.hook}</h2>
<EventWidget /> <EventWidget />
<div className="cal-cta"> <div className="cal-cta">
<Markdownify source={primarycta} /> <Markdownify source={primarycta} />
</div>
</div> </div>
</div> </div>
</div> </section>
</section>
<section className="how-it-works clearfix"> <section className="how-it-works clearfix">
<div className="contained"> <div className="contained">
<div className="half"> <div className="half">
<h4 className="section-label">How it works</h4> <h4 className="section-label">How it works</h4>
<p> <p>
<Markdown source={howitworks} /> <Markdown source={howitworks} />
</p> </p>
<h4 className="section-label">How to join</h4> <h4 className="section-label">How to join</h4>
<p> <p>
<Markdown source={howtojoin} /> <Markdown source={howtojoin} />
</p> </p>
</div>
</div> </div>
</div> </section>
</section> </div>
</div> </Layout>
); );
}; };
export const pageQuery = graphql` export const pageQuery = graphql`
query communityPage { query communityPage {
markdownRemark(id: { regex: "/community/" }) { markdownRemark(fileAbsolutePath: { regex: "/community/" }) {
frontmatter { frontmatter {
headline headline
subhead subhead

View File

@ -1,6 +1,8 @@
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import moment from 'moment'; import moment from 'moment';
import { graphql } from 'gatsby';
import Layout from '../components/layout';
import Markdownify from '../components/markdownify'; import Markdownify from '../components/markdownify';
import VideoEmbed from '../components/video-embed'; import VideoEmbed from '../components/video-embed';
@ -27,152 +29,164 @@ const Features = ({ items }) => (
); );
const HomePage = ({ data }) => { const HomePage = ({ data }) => {
const { landing, updates, contribs } = data; const landing = data.landing.childDataYaml;
const updates = data.updates.childDataYaml;
const contribs = data.contribs.childDataJson;
return ( return (
<div className="landing page"> <Layout>
<section className="landing hero"> <div className="landing page">
<div className="contained"> <section className="landing hero">
<div className="hero-copy"> <div className="contained">
<h1 className="headline"> <div className="hero-copy">
<Markdownify source={landing.hero.headline} /> <h1 className="headline">
</h1> <Markdownify source={landing.hero.headline} />
<span className="subhead"> </h1>
<Markdownify source={landing.hero.subhead} /> <span className="subhead">
</span> <Markdownify source={landing.hero.subhead} />
<span className="cta-header"> </span>
<Markdownify source={landing.cta.button} /> <span className="cta-header">
</span> <Markdownify source={landing.cta.button} />
</div> </span>
<div className="hero-features">
<Features items={landing.hero.devfeatures} />
</div>
<VideoEmbed />
</div>
</section>
<section className="cta">
<div className="cta-primary">
<p>
<span className="hook">
<Markdownify source={landing.cta.primaryhook} />
</span>{' '}
<Markdownify source={landing.cta.primary} />
</p>
<Markdownify source={landing.cta.button} />
</div>
</section>
<section className="whatsnew">
<div className="contained">
<ol>
{updates.updates.slice(0, 3).map(node => (
<a
href={`https://github.com/netlify/netlify-cms/releases/tag/${node.version}`}
key={node.version}
>
<li>
<div className="update-metadata">
<span className="update-version">{node.version}</span>
<span className="update-date">{moment(node.date).format('MMMM D, YYYY')}</span>
</div>
<span className="update-description">
<Markdownify source={node.description} />
</span>
</li>
</a>
))}
</ol>
</div>
</section>
<section className="editors">
<div className="contained">
<h2>
<Markdownify source={landing.editors.hook} />
</h2>
<p id="editor-intro">
<Markdownify source={landing.editors.intro} />
</p>
<div className="editors-features">
<Features items={landing.editors.features} />
</div>
</div>
</section>
<section className="communitysupport">
<div className="contained">
<h2>
<Markdownify source={landing.community.hook} />
</h2>
<div className="community">
<div className="community-features">
<Features items={landing.community.features} />
</div> </div>
<div className="hero-features">
<Features items={landing.hero.devfeatures} />
</div>
<VideoEmbed />
</div> </div>
<div className="contributors feature"> </section>
<h3>{landing.community.contributors}</h3>
<div className="contributor-list"> <section className="cta">
{contribs.contributors.map(user => ( <div className="cta-primary">
<a href={user.profile} title={user.name} key={user.login}> <p>
<img src={user.avatar_url.replace('v=4', 's=32')} alt={user.login} /> <span className="hook">
<Markdownify source={landing.cta.primaryhook} />
</span>{' '}
<Markdownify source={landing.cta.primary} />
</p>
<Markdownify source={landing.cta.button} />
</div>
</section>
<section className="whatsnew">
<div className="contained">
<ol>
{updates.updates.slice(0, 3).map(node => (
<a
href={`https://github.com/netlify/netlify-cms/releases/tag/${node.version}`}
key={node.version}
>
<li>
<div className="update-metadata">
<span className="update-version">{node.version}</span>
<span className="update-date">
{moment(node.date).format('MMMM D, YYYY')}
</span>
</div>
<span className="update-description">
<Markdownify source={node.description} />
</span>
</li>
</a> </a>
))} ))}
</ol>
</div>
</section>
<section className="editors">
<div className="contained">
<h2>
<Markdownify source={landing.editors.hook} />
</h2>
<p id="editor-intro">
<Markdownify source={landing.editors.intro} />
</p>
<div className="editors-features">
<Features items={landing.editors.features} />
</div> </div>
</div> </div>
</div> </section>
</section>
</div> <section className="communitysupport">
<div className="contained">
<h2>
<Markdownify source={landing.community.hook} />
</h2>
<div className="community">
<div className="community-features">
<Features items={landing.community.features} />
</div>
</div>
<div className="contributors feature">
<h3>{landing.community.contributors}</h3>
<div className="contributor-list">
{contribs.contributors.map(user => (
<a href={user.profile} title={user.name} key={user.login}>
<img src={user.avatar_url.replace('v=4', 's=32')} alt={user.login} />
</a>
))}
</div>
</div>
</div>
</section>
</div>
</Layout>
); );
}; };
export const pageQuery = graphql` export const pageQuery = graphql`
query homeQuery { query homeQuery {
updates: dataYaml(id: { regex: "/updates/" }) { updates: file(relativePath: { regex: "/updates/" }) {
updates { childDataYaml {
date updates {
description date
version description
version
}
} }
} }
landing: dataYaml(id: { regex: "/landing/" }) { landing: file(relativePath: { regex: "/landing/" }) {
hero { childDataYaml {
headline hero {
subhead headline
devfeatures { subhead
feature devfeatures {
description feature
description
}
} }
} cta {
cta { primary
primary primaryhook
primaryhook button
button
}
editors {
hook
intro
features {
feature
imgpath
description
} }
} editors {
community { hook
hook intro
features { features {
feature feature
description imgpath
description
}
}
community {
hook
features {
feature
description
}
contributors
} }
contributors
} }
} }
contribs: dataJson(id: { regex: "/contributors/" }) { contribs: file(relativePath: { regex: "/contributors/" }) {
contributors { childDataJson {
name contributors {
profile name
avatar_url profile
login avatar_url
login
}
} }
} }
} }

View File

@ -1,5 +1,8 @@
import React from 'react'; import React from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { graphql } from 'gatsby';
import Layout from '../components/layout';
const BlogPost = ({ data }) => { const BlogPost = ({ data }) => {
const { html, frontmatter } = data.markdownRemark; const { html, frontmatter } = data.markdownRemark;
@ -8,23 +11,25 @@ const BlogPost = ({ data }) => {
const desc = meta_description || description; const desc = meta_description || description;
return ( return (
<div className="docs page"> <Layout>
<Helmet> <div className="docs page">
<title>{title}</title> <Helmet>
{desc && <meta name="description" content={desc} />} <title>{title}</title>
</Helmet> {desc && <meta name="description" content={desc} />}
<div className="container"> </Helmet>
<article className="blog-content" id="blog-content"> <div className="container">
<div className="blog-post-header"> <article className="blog-content" id="blog-content">
<h1>{title}</h1> <div className="blog-post-header">
<p className="meta-info"> <h1>{title}</h1>
by {author} on {date} <p className="meta-info">
</p> by {author} on {date}
</div> </p>
<div dangerouslySetInnerHTML={{ __html: html }} /> </div>
</article> <div dangerouslySetInnerHTML={{ __html: html }} />
</article>
</div>
</div> </div>
</div> </Layout>
); );
}; };

View File

@ -1,7 +1,8 @@
import React from 'react'; import React from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { matchPath } from 'react-router-dom'; import { graphql } from 'gatsby';
import Layout from '../components/layout';
import EditLink from '../components/edit-link'; import EditLink from '../components/edit-link';
import Widgets from '../components/widgets'; import Widgets from '../components/widgets';
import DocsNav from '../components/docs-nav'; import DocsNav from '../components/docs-nav';
@ -20,24 +21,26 @@ const DocPage = ({ data, location, history }) => {
const { nav, page, widgets, menu } = data; const { nav, page, widgets, menu } = data;
const docsNav = toMenu(menu.siteMetadata.menu.docs, nav); const docsNav = toMenu(menu.siteMetadata.menu.docs, nav);
const showWidgets = matchPath(location.pathname, { path: '/docs/widgets' }); const showWidgets = location.pathname.indexOf('/docs/widgets') !== -1;
return ( return (
<div className="docs detail page"> <Layout>
<Helmet title={page.frontmatter.title} /> <div className="docs detail page">
<div className="container"> <Helmet title={page.frontmatter.title} />
<aside id="sidebar" className="sidebar"> <div className="container">
<DocsNav items={docsNav} location={location} /> <aside id="sidebar" className="sidebar">
<MobileNav items={docsNav} history={history} /> <DocsNav items={docsNav} location={location} />
</aside> <MobileNav items={docsNav} history={history} />
<article className="docs-content" id="docs-content"> </aside>
<EditLink path={page.fields.path} /> <article className="docs-content" id="docs-content">
<h1>{page.frontmatter.title}</h1> <EditLink path={page.fields.path} />
<div dangerouslySetInnerHTML={{ __html: page.html }} /> <h1>{page.frontmatter.title}</h1>
{showWidgets && <Widgets widgets={widgets} />} <div dangerouslySetInnerHTML={{ __html: page.html }} />
</article> {showWidgets && <Widgets widgets={widgets} />}
</article>
</div>
</div> </div>
</div> </Layout>
); );
}; };

File diff suppressed because it is too large Load Diff