From 050b6ef98fae7a534a172413e0d7e0316f3c9257 Mon Sep 17 00:00:00 2001 From: Adam Mould Date: Tue, 5 Jun 2018 19:49:36 +0100 Subject: [PATCH] [gatsby-source-wordpress] Treat wp settings as a known type for inclusion (#5708) * Append wordpress_id to wp settings to prevent exclusion Signed-off-by: Adam Mould * Treat wp settings as a known type Signed-off-by: Adam Mould * Comments to explain normalize functions Signed-off-by: Adam Mould --- packages/gatsby-source-wordpress/src/normalize.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-source-wordpress/src/normalize.js b/packages/gatsby-source-wordpress/src/normalize.js index cc79b43d32fae..62becaf9200ed 100644 --- a/packages/gatsby-source-wordpress/src/normalize.js +++ b/packages/gatsby-source-wordpress/src/normalize.js @@ -137,12 +137,20 @@ exports.liftRenderedField = entities => }) // Exclude entities of unknown shape +// Assume all entities contain a wordpress_id, except for whitelisted type wp_settings exports.excludeUnknownEntities = entities => - entities.filter(e => e.wordpress_id) // Excluding entities without ID + entities.filter(e => e.wordpress_id || e.__type === `wordpress__wp_settings`) // Excluding entities without ID, or WP Settings +// Create node ID from known entities +// excludeUnknownEntities whitelisted types don't contain a wordpress_id +// we create the node ID based upon type if the wordpress_id doesn't exist exports.createGatsbyIds = (createNodeId, entities) => entities.map(e => { - e.id = createNodeId(`${e.__type}-${e.wordpress_id.toString()}`) + if (e.wordpress_id) { + e.id = createNodeId(`${e.__type}-${e.wordpress_id.toString()}`) + } else { + e.id = createNodeId(e.__type) + } return e })