Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
CMeeg committed Oct 4, 2020
2 parents c1a8a77 + 7f47b1e commit 298721e
Show file tree
Hide file tree
Showing 5 changed files with 658 additions and 7,395 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## 0.5.0 (2020-10-04)

### Bug Fixes

* Adds rich text assets to assets collection ([963487e](https://github.com/CMeeg/gridsome-source-kentico-kontent/commit/963487e0347aa2f919e7c3ffc7df0084ec6ad753)), closes [#15](https://github.com/CMeeg/gridsome-source-kentico-kontent/issues/15)

## 0.4.1 (2020-04-13)

### Bug Fixes
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meeg/gridsome-source-kentico-kontent",
"version": "0.4.1",
"version": "0.5.0",
"description": "Kentico Kontent data source plugin for Gridsome.",
"author": "Chris Meagher",
"license": "MIT",
Expand All @@ -23,21 +23,21 @@
"change-case": "^3.1.0",
"cheerio": "^1.0.0-rc.3",
"debug": "^4.1.1",
"lodash": "^4.17.15",
"lodash": "^4.17.20",
"rxjs": "^6.5.3"
},
"peerDependencies": {
"gridsome": "~0.7.8"
},
"devDependencies": {
"eslint": "^6.5.1",
"eslint-config-standard": "^14.1.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-node": "10.0.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"genversion": "^2.2.0",
"standard-version": "^7.0.0"
"genversion": "^2.2.1",
"standard-version": "^8.0.2"
},
"publishConfig": {
"access": "public"
Expand Down
10 changes: 9 additions & 1 deletion src/GridsomeContentItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class GridsomeContentItem extends ContentItem {
},
assetFields: [],
linkedItemFields: [],
taxonomyFields: []
taxonomyFields: [],
richTextFields: []
};

return node;
Expand Down Expand Up @@ -195,6 +196,13 @@ class GridsomeContentItem extends ContentItem {
const fieldName = field.fieldName;
const html = this.richTextHtmlTransformer.transformRichTextHtml(field);

const richTextField = {
fieldName,
assets: field.images
};

node.richTextFields.push(richTextField);

this.addField(node, fieldName, html);
}

Expand Down
47 changes: 47 additions & 0 deletions src/KenticoKontentSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,58 @@ class KenticoKontentSource {
this.logger.log('Creating Gridsome node for asset %o', asset);

assetCollection.addNode(asset);
} else if (existingNode.name === null) {
// In case the asset was previously created as rich text asset

this.logger.log('Updating Gridsome node for asset %o', asset);

existingNode.name = asset.name;
existingNode.contract.name = asset.contract.name;
existingNode.type = asset.type;
existingNode.contract.type = asset.contract.type;
existingNode.size = asset.size;
existingNode.contract.size = asset.contract.size;
}
}

collection.addReference(fieldName, typeName);
}

// Add assets from rich text fields
for (const assetField of node.richTextFields) {
const assets = assetField.assets;

for (const asset of assets) {
const id = asset.url;

const existingNode = assetCollection.findNode({ id });
if (existingNode === null) {
const transformedAsset = {
contract: {
name: null,
description: asset.description,
type: null,
size: null,
url: asset.url,
width: asset.width,
height: asset.height
},
name: null,
type: null,
size: null,
description: asset.description,
url: asset.url,
width: asset.width,
height: asset.height,
id: asset.url
};

this.logger.log('Creating Gridsome node for asset from rich text field %o', transformedAsset);

assetCollection.addNode(transformedAsset);
}
}
}
}

addItemLinkNode(store, node) {
Expand Down
Loading

0 comments on commit 298721e

Please sign in to comment.