Skip to content

Commit 0f768d4

Browse files
ethansharM-i-k-e-l
andauthored
Infra/unify docs (#1036)
* Fix docs * change docs:build script * Fix docs:build script * dont include docs building in CI build due to issues * prepare a uilib-docs package * remove private field from package.json * exclude public folder in npmignore * Change imports to require * export markdown plugin as a function to inject a path * use relative path for layout plugin * filter invalid markdown pages * update version * Update uilib-docs/.npmignore Co-authored-by: Miki <[email protected]> Co-authored-by: Miki <[email protected]>
1 parent 56fde30 commit 0f768d4

File tree

7 files changed

+33
-17
lines changed

7 files changed

+33
-17
lines changed

uilib-docs/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
.npmignore
3+
4+
.cache
5+
public

uilib-docs/configurations/pageCreators/createMarkdownPages.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = async ({graphql, boundActionCreators}) => {
44
const {createPage} = boundActionCreators;
55
const result = await graphql(`
66
{
7-
allFile(filter: {sourceInstanceName: {eq: "markdown-pages"}}) {
7+
allFile(filter: {sourceInstanceName: {eq: "markdown-pages"}, childMarkdownRemark: {frontmatter: {path: {ne: null}}}}) {
88
edges {
99
node {
1010
id
@@ -24,11 +24,13 @@ module.exports = async ({graphql, boundActionCreators}) => {
2424
`);
2525

2626
result.data.allFile.edges.forEach(({node}) => {
27-
createPage({
28-
name: node.name,
29-
path: node.childMarkdownRemark.frontmatter.path,
30-
component: path.resolve(`src/templates/markdownTemplate.js`),
31-
context: {} // additional data can be passed via context
32-
});
27+
if (node.childMarkdownRemark.frontmatter.path) {
28+
createPage({
29+
name: node.name,
30+
path: node.childMarkdownRemark.frontmatter.path,
31+
component: path.resolve(`src/templates/markdownTemplate.js`),
32+
context: {} // additional data can be passed via context
33+
});
34+
}
3335
});
3436
};

uilib-docs/configurations/plugins.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const path = require('path');
2+
13
const manifestPlugin = [
24
{
35
resolve: `gatsby-plugin-manifest`,
@@ -13,12 +15,12 @@ const manifestPlugin = [
1315
}
1416
];
1517

16-
const markdownPagesPlugin = [
18+
const markdownPagesPlugin = (path = `${__dirname}/../../markdowns/`) => [
1719
{
1820
resolve: `gatsby-source-filesystem`,
1921
options: {
2022
name: `markdown-pages`,
21-
path: `${__dirname}/../../markdowns/`
23+
path
2224
}
2325
},
2426
`gatsby-transformer-remark`
@@ -73,7 +75,7 @@ const layoutPlugin = [
7375
{
7476
resolve: `gatsby-plugin-layout`,
7577
options: {
76-
component: require.resolve(`${__dirname}/../src/components/layout.js`)
78+
component: require.resolve(`${path.resolve('./')}/src/components/layout.js`)
7779
}
7880
}
7981
];

uilib-docs/gatsby-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
plugins: [
1111
`gatsby-plugin-react-helmet`,
1212
`gatsby-plugin-sass`,
13-
...markdownPagesPlugin,
13+
...markdownPagesPlugin(),
1414
...componentsDocgenPlugin,
1515
...incubatorComponentsDocgenPlugin,
1616
...nativeComponentsDocgenPlugin,

uilib-docs/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const PageCreators = require('./configurations/pageCreators');
2+
const Plugins = require('./configurations/plugins');
3+
4+
module.exports = {
5+
PageCreators,
6+
Plugins
7+
};

uilib-docs/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "gatsby-starter-default",
3-
"private": true,
4-
"description": "A simple starter to get up and developing quickly with Gatsby",
5-
"version": "0.1.0",
6-
"author": "Kyle Mathews <[email protected]>",
2+
"name": "uilib-docs",
3+
"description": "uilib docs template",
4+
"version": "1.0.4",
5+
"author": "Ethan Sharabi <[email protected]>",
6+
"main": "index.js",
77
"dependencies": {
88
"classnames": "^2.2.6",
99
"gatsby": "^2.0.0",

uilib-docs/src/components/navbar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class Navbar extends Component {
125125
}
126126
}
127127
}
128-
allFile(filter: {sourceInstanceName: {eq: "markdown-pages"}}) {
128+
allFile(filter: {sourceInstanceName: {eq: "markdown-pages"}, childMarkdownRemark: {frontmatter: {path: {ne: null}}}}) {
129129
edges {
130130
node {
131131
childMarkdownRemark {

0 commit comments

Comments
 (0)