Skip to content

Commit 050b6ef

Browse files
Adam-Mouldpieh
authored andcommitted
[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 <[email protected]> * Treat wp settings as a known type Signed-off-by: Adam Mould <[email protected]> * Comments to explain normalize functions Signed-off-by: Adam Mould <[email protected]>
1 parent 0e4cfd6 commit 050b6ef

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/gatsby-source-wordpress/src/normalize.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,20 @@ exports.liftRenderedField = entities =>
137137
})
138138

139139
// Exclude entities of unknown shape
140+
// Assume all entities contain a wordpress_id, except for whitelisted type wp_settings
140141
exports.excludeUnknownEntities = entities =>
141-
entities.filter(e => e.wordpress_id) // Excluding entities without ID
142+
entities.filter(e => e.wordpress_id || e.__type === `wordpress__wp_settings`) // Excluding entities without ID, or WP Settings
142143

144+
// Create node ID from known entities
145+
// excludeUnknownEntities whitelisted types don't contain a wordpress_id
146+
// we create the node ID based upon type if the wordpress_id doesn't exist
143147
exports.createGatsbyIds = (createNodeId, entities) =>
144148
entities.map(e => {
145-
e.id = createNodeId(`${e.__type}-${e.wordpress_id.toString()}`)
149+
if (e.wordpress_id) {
150+
e.id = createNodeId(`${e.__type}-${e.wordpress_id.toString()}`)
151+
} else {
152+
e.id = createNodeId(e.__type)
153+
}
146154
return e
147155
})
148156

0 commit comments

Comments
 (0)