Skip to content

Commit

Permalink
chore: Pull list of components from constants inside plugin instead o…
Browse files Browse the repository at this point in the history
…f config
  • Loading branch information
jerelmiller committed Jun 28, 2020
1 parent 05af37c commit 541f9bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ module.exports = {
resolve: 'gatsby-source-newrelic-sdk',
options: {
release: 'release-1093',
components: ['Button', 'BlockText'],
apis: ['logger', 'nerdlet'],
},
},
'gatsby-plugin-meta-redirect',
Expand Down
7 changes: 4 additions & 3 deletions plugins/gatsby-source-newrelic-sdk/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const loadSdk = require('./src/loadSdk');
const { getComponentDoc, getApiDoc } = require('./src/docInfo');
const { DOCUMENTED_APIS, DOCUMENTED_COMPONENTS } = require('./src/constants');

const hasOwnProperty = (obj, name) =>
Object.prototype.hasOwnProperty.call(obj, name);
Expand Down Expand Up @@ -106,12 +107,12 @@ exports.createResolvers = ({ createResolvers }) => {

exports.sourceNodes = async (
{ actions, createNodeId, createContentDigest },
{ release, components = [], apis = [] }
{ release }
) => {
const { createNode } = actions;
const sdk = await loadSdk(release);

components.forEach((name) => {
DOCUMENTED_COMPONENTS.forEach((name) => {
const data = getComponentDoc(name, sdk);

if (data) {
Expand All @@ -128,7 +129,7 @@ exports.sourceNodes = async (
}
});

apis.forEach((name) => {
DOCUMENTED_APIS.forEach((name) => {
const data = getApiDoc(name, sdk);

if (data) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/gatsby-source-newrelic-sdk/src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports.DOCUMENTED_APIS = ['logger', 'nerdlet'];
module.exports.DOCUMENTED_COMPONENTS = ['AccountPicker', 'Button'];

0 comments on commit 541f9bd

Please sign in to comment.