Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cmpsr/contentful-core

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cmpsr/contentful-core - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

6

CHANGELOG.md
# @cmpsr/contentful-core
## 0.1.7
### Patch Changes
- ac62e76: Adds try/catch to ComponentRenderer
## 0.1.6

@@ -4,0 +10,0 @@

45

lib/components/ComponentRenderer/ComponentRenderer.js

@@ -36,29 +36,34 @@ "use strict";

const contentfulContext = (0, _react.useContext)(_context.ContentfulContext);
const componentMap = Object.assign({}, contentfulContext === null || contentfulContext === void 0 ? void 0 : contentfulContext.componentMap, componentMapOverrides);
try {
const contentfulContext = (0, _react.useContext)(_context.ContentfulContext);
const componentMap = Object.assign({}, contentfulContext === null || contentfulContext === void 0 ? void 0 : contentfulContext.componentMap, componentMapOverrides);
if (Array.isArray(data)) {
return data.map((item, index) => (0, _renderers.renderFromContentfulModel)({
componentMap
}, _objectSpread(_objectSpread(_objectSpread({}, item), rest), {}, {
className
}), index, parentId));
}
if (Array.isArray(data)) {
return data.map((item, index) => (0, _renderers.renderFromContentfulModel)({
componentMap
}, _objectSpread(_objectSpread(_objectSpread({}, item), rest), {}, {
className
}), index, parentId));
}
if ((0, _utils.isCollectionShape)(data)) {
const collectionKey = Object.keys(data)[0];
return data[collectionKey].items.map((item, index) => (0, _renderers.renderFromContentfulModel)({
if ((0, _utils.isCollectionShape)(data)) {
const collectionKey = Object.keys(data)[0];
return data[collectionKey].items.map((item, index) => (0, _renderers.renderFromContentfulModel)({
componentMap
}, _objectSpread(_objectSpread(_objectSpread({}, item), rest), {}, {
className
}), index, parentId));
}
return (0, _renderers.renderFromContentfulModel)({
componentMap
}, _objectSpread(_objectSpread(_objectSpread({}, item), rest), {}, {
}, _objectSpread(_objectSpread(_objectSpread({}, data), rest), {}, {
className
}), index, parentId));
}), index, parentId);
} catch (e) {
console.log('error', e);
return null;
}
return (0, _renderers.renderFromContentfulModel)({
componentMap
}, _objectSpread(_objectSpread(_objectSpread({}, data), rest), {}, {
className
}), index, parentId);
};
exports.ComponentRenderer = ComponentRenderer;

@@ -27,23 +27,26 @@ "use strict";

}) => {
const {
componentMap: componentMapDefault,
queryMap: queryMapDefault
} = (0, _react.useContext)(_context.ContentfulContext);
const query = (queryMapOverride || queryMapDefault)[type]();
const {
data
} = (0, _reactHooks.useQuery)(query, {
variables
});
if (!data) return null;
const key = Object.keys(data)[0];
if (!key) return null;
const dataToParse = key.indexOf('Collection') >= 0 ? data[key].items[0] : data[key];
return /*#__PURE__*/_react.default.createElement(_ComponentRenderer.ComponentRenderer, {
className: className,
data: dataToParse,
componentMap: componentMapOverride || componentMapDefault
});
try {
const {
componentMap: componentMapDefault,
queryMap: queryMapDefault
} = (0, _react.useContext)(_context.ContentfulContext);
const query = (queryMapOverride || queryMapDefault)[type]();
const {
data
} = (0, _reactHooks.useQuery)(query, {
variables
});
const key = Object.keys(data)[0];
const dataToParse = key.indexOf('Collection') >= 0 ? data[key].items[0] : data[key];
return /*#__PURE__*/_react.default.createElement(_ComponentRenderer.ComponentRenderer, {
className: className,
data: dataToParse,
componentMap: componentMapOverride || componentMapDefault
});
} catch (e) {
console.log('error', e);
return null;
}
};
exports.ComponentRendererWithQuery = ComponentRendererWithQuery;

@@ -38,3 +38,3 @@ "use strict";

default: {
bg: 'fill-primary-100'
bg: 'fill-primary-900'
}

@@ -41,0 +41,0 @@ }

{
"name": "@cmpsr/contentful-core",
"version": "0.1.6",
"version": "0.1.7",
"description": "Base Composer components for standing up a React/NextJS app that can dynamically render components based on Contentful Model types mapped to components and queries.",

@@ -43,3 +43,3 @@ "author": "Ryan Hefner <hi@ryanhefner.com>",

},
"gitHead": "c42cecfc55b51bdc2ea09943ecbe5efced5a7a05"
"gitHead": "ea6934e997d7367347a6cdb63d281284f936490e"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc