Skip to content

Commit

Permalink
Move 'children' key from xml parser to xmlChildren so it doesn't brea…
Browse files Browse the repository at this point in the history
…k Gatsby fixes #2083 (#2108)
  • Loading branch information
KyleAMathews authored Sep 14, 2017
1 parent 97c82a9 commit 9f79b78
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ Array [
"attributes": Object {
"id": "bk101",
},
"children": Array [
"children": Array [],
"content": "",
"id": "bk101",
"internal": Object {
"contentDigest": "446732570969e52599dded1ba4941b65",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
"xmlChildren": Array [
Object {
"attributes": Object {},
"children": Array [],
Expand Down Expand Up @@ -46,22 +55,23 @@ Array [
"name": "description",
},
],
"content": "",
"id": "bk101",
"internal": Object {
"contentDigest": "446732570969e52599dded1ba4941b65",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
},
],
Array [
Object {
"attributes": Object {
"id": "bk102",
},
"children": Array [
"children": Array [],
"content": "",
"id": "bk102",
"internal": Object {
"contentDigest": "f1aadb72f7fc4e80a8b0f44899a4c30c",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
"xmlChildren": Array [
Object {
"attributes": Object {},
"children": Array [],
Expand Down Expand Up @@ -101,14 +111,6 @@ Array [
"name": "description",
},
],
"content": "",
"id": "bk102",
"internal": Object {
"contentDigest": "f1aadb72f7fc4e80a8b0f44899a4c30c",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
},
],
]
Expand All @@ -122,7 +124,16 @@ Array [
"attributes": Object {
"id": "bk101",
},
"children": Array [
"children": Array [],
"content": "",
"id": "bk101",
"internal": Object {
"contentDigest": "446732570969e52599dded1ba4941b65",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
"xmlChildren": Array [
Object {
"attributes": Object {},
"children": Array [],
Expand Down Expand Up @@ -161,14 +172,6 @@ Array [
"name": "description",
},
],
"content": "",
"id": "bk101",
"internal": Object {
"contentDigest": "446732570969e52599dded1ba4941b65",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
},
"parent": Object {
"children": Array [],
Expand Down Expand Up @@ -213,7 +216,16 @@ Array [
"attributes": Object {
"id": "bk102",
},
"children": Array [
"children": Array [],
"content": "",
"id": "bk102",
"internal": Object {
"contentDigest": "f1aadb72f7fc4e80a8b0f44899a4c30c",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
"xmlChildren": Array [
Object {
"attributes": Object {},
"children": Array [],
Expand Down Expand Up @@ -253,14 +265,6 @@ Array [
"name": "description",
},
],
"content": "",
"id": "bk102",
"internal": Object {
"contentDigest": "f1aadb72f7fc4e80a8b0f44899a4c30c",
"type": "NodeNameXml",
},
"name": "book",
"parent": "whatever",
},
"parent": Object {
"children": Array [],
Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby-transformer-xml/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ async function onCreateNode({ node, boundActionCreators, loadNodeContent }) {
.createHash(`md5`)
.update(objStr)
.digest(`hex`)
if (obj.children) {
obj.xmlChildren = obj.children
delete obj.children
}
return {
...obj,
id: obj.attributes.id ? obj.attributes.id : `${node.id} [${i}] >>> XML`,
parent: node.id,
children: [],
internal: {
contentDigest,
type: _.upperFirst(_.camelCase(`${node.name} xml`)),
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/joi-schemas/joi.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const nodeSchema = Joi.object()
type: Joi.string().required(),
owner: Joi.string().required(),
fieldOwners: Joi.array(),
content: Joi.string().allow(""),
content: Joi.string().allow(``),
}),
})
.unknown()

0 comments on commit 9f79b78

Please sign in to comment.