Skip to content

Commit

Permalink
fix update internal type setting + addsupport for number and url_slug
Browse files Browse the repository at this point in the history
  • Loading branch information
Simply007 committed Nov 20, 2019
1 parent b1ce2ec commit da45155
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kentico/gatsby-source-kontent",
"version": "4.1.0-beta1",
"version": "4.1.0-beta2",
"description": "Gatsby source plugin for Kentico Kontent",
"main": "./gatsby-node.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const customTrackingHeader = {
header: 'X-KC-SOURCE',
value: '@kentico/gatsby-source-kontent;4.1.0-beta1',
value: '@kentico/gatsby-source-kontent;4.1.0-beta2',
};

module.exports = {
Expand Down
32 changes: 20 additions & 12 deletions src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,26 @@ const performUpdate = (
const updatedItem = _.cloneDeep(itemNode);

const changedElement = updatedItem.elements[itemChangedCodenames[0]];
// TODO add support for all another elements
if (changedElement.type === 'text') {
changedElement.value = itemToUpdate
.elements[itemChangedCodenames[0]]
.value;
updatedItem.internal = getNodeInternal(
'item',
itemToUpdate,
includeRawContent,
updatedItem.system.codename
);
createNode(updatedItem);

switch (changedElement.type) {
case 'text':
case 'number':
case 'url_slug':
changedElement.value = itemToUpdate
.elements[itemChangedCodenames[0]]
.value;
updatedItem.internal = getNodeInternal(
'item',
itemToUpdate,
includeRawContent,
updatedItem.system.type
);
createNode(updatedItem);
break;

default:
// TODO add support for all another elements
break;
}
}
}
Expand Down

0 comments on commit da45155

Please sign in to comment.