Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Dec 15, 2017
1 parent 9c6c98d commit c683180
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-source-datocms",
"version": "1.0.13",
"version": "1.0.14",
"description": "Gatsby source plugin for building websites using DatoCMS as data source",
"main": "index.js",
"scripts": {
Expand Down
49 changes: 24 additions & 25 deletions src/createItemNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,36 @@ module.exports = function createItemNodes(repo, createNode) {
const key = camelize(field.apiKey);

switch (fieldType) {
case 'link':
{
itemNode[`${key}___NODE`] = value ?
itemNodeId(repo, value, locale) :
null;

break;
case 'link': {
if (value) {
itemNode[`${key}___NODE`] = itemNodeId(repo, value, locale);
}
case 'rich_text':
case 'links':
{
itemNode[`${key}___NODE`] = (value || []).map(id => itemNodeId(repo, id, locale));
break;
}
case 'text':
{
let mediaType = 'text/plain';

if (field.appeareance.type === 'markdown') {
mediaType = 'text/markdown';
} else if (field.appeareance.type === 'wysiwyg') {
mediaType = 'text/html';
}
break;
}
case 'rich_text':
case 'links': {
itemNode[`${key}___NODE`] = (value || []).map(id => itemNodeId(repo, id, locale));
break;
}
case 'text': {
let mediaType = 'text/plain';

itemNode[`${key}Node___NODE`] = createTextNode(itemNode, key, value, mediaType, createNode);
itemNode[key] = value;
break;
if (field.appeareance.type === 'markdown') {
mediaType = 'text/markdown';
} else if (field.appeareance.type === 'wysiwyg') {
mediaType = 'text/html';
}

itemNode[`${key}Node___NODE`] = createTextNode(itemNode, key, value, mediaType, createNode);
itemNode[key] = value;
break;
}
case 'image':
case 'file': {
itemNode[`${key}___NODE`] = createAssetNode(itemNode, key, value, itemsRepo, createNode);
if (value) {
itemNode[`${key}___NODE`] = createAssetNode(itemNode, key, value, itemsRepo, createNode);
}
break;
}
case 'gallery': {
Expand Down

0 comments on commit c683180

Please sign in to comment.