-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
beardedfinch
committed
Jan 22, 2018
1 parent
7be28e1
commit fc11c3e
Showing
53 changed files
with
2,361 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,64 @@ | ||
var CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
var path = require('path'); | ||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
const path = require(`path`) | ||
|
||
exports.modifyWebpackConfig = function (config, env) { | ||
config.config.plugin('inventory-copy-plugin', CopyWebpackPlugin, [[ | ||
{ from: path.join(__dirname, 'src/pages/data.json') , to: path.join(__dirname, 'public/data.json')} | ||
]]); | ||
return config; | ||
} | ||
}; | ||
|
||
exports.modifyWebpackConfig = ({ config, stage }) => { | ||
if (stage === "build-html") { | ||
config.loader("null", { | ||
test: /datamaps/, | ||
loader: "null-loader", | ||
}) | ||
} | ||
}; | ||
|
||
const { createFilePath } = require(`gatsby-source-filesystem`) | ||
|
||
exports.onCreateNode = ({ node, getNode, boundActionCreators }) => { | ||
const { createNodeField } = boundActionCreators | ||
if (node.internal.type === `MarkdownRemark`) { | ||
const slug = createFilePath({ node, getNode, basePath: `pages` }) | ||
createNodeField({ | ||
node, | ||
name: `slug`, | ||
value: slug, | ||
}) | ||
} | ||
} | ||
|
||
exports.createPages = ({ graphql, boundActionCreators }) => { | ||
const { createPage } = boundActionCreators | ||
return new Promise((resolve, reject) => { | ||
graphql(` | ||
{ | ||
allMarkdownRemark { | ||
edges { | ||
node { | ||
fields { | ||
slug | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
).then(result => { | ||
result.data.allMarkdownRemark.edges.forEach(({ node }) => { | ||
createPage({ | ||
path: node.fields.slug, | ||
component: path.resolve(`./src/templates/docs-markdown.js`), | ||
context: { | ||
// Data passed to context is available in page queries as GraphQL variables. | ||
slug: node.fields.slug, | ||
}, | ||
}) | ||
}) | ||
resolve() | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import React from "react" | ||
import Link from "gatsby-link" | ||
import cx from 'classnames' | ||
import DocSidebarContainer from "../containers/DocSidebarContainer"; | ||
|
||
|
||
const Section = props => ( | ||
<div className="pad-l-1 pad-b-4"> | ||
<h3> | ||
{props.title} | ||
</h3> | ||
<SectionLinks | ||
{...props} | ||
title={props.title} | ||
isTutorial={props.title === `Tutorial`} | ||
/> | ||
</div> | ||
) | ||
|
||
const SectionLinks = props => { | ||
|
||
return ( | ||
<ul> | ||
{props.items.map((item, index) => ( | ||
<SectionLink | ||
node={item} | ||
children={item.items} | ||
key={index} | ||
isInline={props.isInline} | ||
toggleSection={props.toggleSection} | ||
activeHeader={props.activeHeader} | ||
/> | ||
))} | ||
</ul> | ||
) | ||
} | ||
|
||
const SectionLink = props => { | ||
|
||
let childnodes = null | ||
if (props.children) { | ||
childnodes = props.children.map((childnode, index) => ( | ||
<SectionLink key={index} node={childnode} children={childnode.items} isChild /> | ||
)) | ||
} | ||
|
||
let item = props.node | ||
// If the last character is a * then the doc page is still in draft | ||
let isDraft = item.title.slice(-1) === `*` | ||
let title = isDraft ? item.title.slice(0, -1) : item.title | ||
|
||
let isHeader = false | ||
if (Object.keys(item).indexOf("link") === -1) { | ||
isHeader = true | ||
} | ||
const itemCx = cx({ | ||
'row': true, | ||
'sidebar-item': !isHeader, | ||
'sidebar-header': isHeader, | ||
'depth-2': !props.isChild, | ||
'depth-3': props.isChild, | ||
}) | ||
|
||
return ( | ||
<li> | ||
{Object.keys(item).indexOf("link") === -1 ? ( | ||
<span className={itemCx + (props.activeHeader.indexOf(title) > -1 ? ' ': ' collapsed')} | ||
title={title} | ||
onClick={props.toggleSection}> | ||
{title} | ||
</span> | ||
) : item.link.charAt(0) === `#` ? ( | ||
<a href={item.link} className={itemCx}> | ||
{title} | ||
</a> | ||
) : ( | ||
<Link | ||
to={item.link} | ||
key={item.title} | ||
className={itemCx} | ||
activeClassName="sidebar-item-active" | ||
exact | ||
> | ||
{title} | ||
</Link> | ||
) | ||
} | ||
{childnodes ? | ||
<ul className={item.collapse ? (props.activeHeader.indexOf(title) > -1 ? 'display-block': 'display-none') : ' '}> | ||
{childnodes} | ||
</ul> : null} | ||
</li> | ||
) | ||
} | ||
|
||
class DocSidebar extends React.Component { | ||
render() { | ||
const menu = this.props.yaml | ||
const isInline = this.props.inline | ||
|
||
return ( | ||
<div className="doc-sidebar"> | ||
{menu.map((section, index) => ( | ||
<div | ||
key={index} | ||
|
||
> | ||
<Section | ||
{...section} | ||
title={section.title} | ||
index={index} | ||
isInline={isInline} | ||
activeHeader={this.props.activeHeader} | ||
toggleSection={this.props.toggleSection} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
DocSidebar.displayName = 'components/DocSidebar' | ||
export default DocSidebarContainer(DocSidebar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.