Files
shields/gatsby-node.js
dependabot-preview[bot] 3a31721631 Build(deps): bump js-yaml from 3.14.1 to 4.0.0; run [DynamicYaml] (#6026)
* Build(deps): bump js-yaml from 3.14.1 to 4.0.0

Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.14.1 to 4.0.0.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.14.1...4.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* deps: apply js-yaml v4 changes

* deps: js-yaml v4 updates in gatsby config

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-01-10 15:23:32 +00:00

50 lines
1.3 KiB
JavaScript

'use strict'
/*
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
const fs = require('fs')
const yaml = require('js-yaml')
const envFlag = require('node-env-flag')
const includeDevPages = envFlag(process.env.INCLUDE_DEV_PAGES, true)
const { categories } = yaml.load(
fs.readFileSync('./service-definitions.yml', 'utf8')
)
// Often in Gatsby context gets piped through GraphQL, but GraphQL adds
// unnecessary complexity here, so this uses the programmatic API.
// https://www.gatsbyjs.org/docs/using-gatsby-without-graphql/#the-approach-fetch-data-and-use-gatsbys-createpages-api
async function createPages({ actions: { createPage } }) {
if (includeDevPages) {
createPage({
path: '/dev/styles',
component: require.resolve(
'./frontend/components/development/style-page.tsx'
),
})
createPage({
path: '/dev/logos',
component: require.resolve(
'./frontend/components/development/logo-page.tsx'
),
})
}
categories.forEach(category => {
const { id } = category
createPage({
path: `/category/${id}`,
component: require.resolve('./frontend/components/main.tsx'),
// `context` provided here becomes `props.pageContext` on the page.
context: { category },
})
})
}
module.exports = { createPages }