Skip to content

Commit

Permalink
Remove Netlify CMS (2/2) (#711)
Browse files Browse the repository at this point in the history
This moves files from `www/src/cms` to `www/src/pages`.

It also runs the files through Prettier.
  • Loading branch information
danoc authored Aug 4, 2020
1 parent 44abf3c commit 45ef2f1
Show file tree
Hide file tree
Showing 26 changed files with 485 additions and 713 deletions.
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ www/public
www/.cache
# Prevent Yarn and Prettier from conflicting.
package.json
# Ignore the Netlify CMS files because those are edited through a WYSIWYG interface.
www/src/cms/**/*.md

coverage
yarn.lock
Expand Down
7 changes: 0 additions & 7 deletions www/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ module.exports = {
path: `${__dirname}/src/pages`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'cms',
path: `${__dirname}/src/cms`,
},
},
{
resolve: 'gatsby-plugin-sass',
options: {
Expand Down
69 changes: 0 additions & 69 deletions www/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,72 +58,3 @@ exports.onCreateWebpackConfig = ({ actions }) => {
},
});
};

/**
* Create pages from the Markdown files created by Netlify CMS.
*
*/
exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage } = actions;

const result = await graphql(`
query {
allFile(filter: { sourceInstanceName: { eq: "cms" }, ext: { eq: ".md" } }) {
edges {
node {
name
relativeDirectory
relativePath
childMdx {
id
frontmatter {
title
description
}
}
}
}
}
}
`);

if (result.errors) {
reporter.panicOnBuild("Can't load MDX files used by Netlify CMS.");
}

result.data.allFile.edges.forEach(({ node }) => {
let slug;

// These are all the collections that we previously used in Netlify CMS. This will be
// removed once we remove the CMS.
if (node.relativeDirectory === 'overview') {
slug = `/overview/${node.name}/`;
} else if (node.relativeDirectory === 'guide') {
slug = `/guide/product/${node.name}/`;
} else if (node.relativeDirectory === 'components-ios') {
slug = `/components/${node.name}/ios/`;
} else if (node.relativeDirectory === 'components-android') {
slug = `/components/${node.name}/android/`;
} else if (node.relativeDirectory === 'components-usage') {
slug = `/components/${node.name}/usage/`;
} else {
reporter.panicOnBuild(
`Can't generate a URL for the Markdown file in \`${node.relativePath}\`. Take a look at \`createPages\` in \`gatsby-node.js\`.`,
);
}

createPage({
path: slug,
component: path.resolve(`./src/components/cms/index.jsx`),
context: {
id: node.childMdx.id,
relatedComponentsGlob: `/components/${node.name}/*/`,
isComponent: slug.startsWith('/components/'),
frontmatter: {
title: node.childMdx.frontmatter.title,
description: node.childMdx.frontmatter.description,
},
},
});
});
};
102 changes: 0 additions & 102 deletions www/src/cms/components-android/button.md

This file was deleted.

19 changes: 0 additions & 19 deletions www/src/cms/components-android/toast.md

This file was deleted.

33 changes: 0 additions & 33 deletions www/src/cms/components-usage/popover.md

This file was deleted.

Loading

0 comments on commit 45ef2f1

Please sign in to comment.