New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

contentful-hugo

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-hugo - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

111

index.js

@@ -286,113 +286,2 @@ const contentful = require('contentful');

}
if (contentSettings.isHeadless) {
frontMatter.headless = true;
mkdirp.sync(`.${contentSettings.directory + item.sys.id}`);
}
frontMatter.updated = item.sys.updatedAt;
frontMatter.createdAt = item.sys.createdAt;
frontMatter.date = item.sys.createdAt;
for (const field of Object.keys(item.fields)) {
if (field === contentSettings.mainContent) {
// skips to prevent duplicating mainContent in frontmatter
continue;
} else if (field === 'date') {
// convert dates with time to ISO String so Hugo can properly Parse
const d = item.fields[field];
if (d.length > 10) {
frontMatter.date = new Date(d).toISOString();
} else {
frontMatter.date = d;
}
continue;
}
const fieldContent = item.fields[field];
switch (typeof fieldContent) {
case 'object':
if ('sys' in fieldContent) {
frontMatter[field] = {};
switch (fieldContent.sys.type) {
case 'Asset':
frontMatter[field] = getAssetFields(
fieldContent
);
break;
case 'Entry':
frontMatter[field] = getEntryFields(
fieldContent
);
break;
default:
frontMatter[field] = fieldContent;
break;
}
}
// rich text (see rich text function)
else if ('nodeType' in fieldContent) {
frontMatter[field] = [];
frontMatter[
`${field}_plaintext`
] = richTextToPlain(fieldContent);
const nodes = fieldContent.content;
for (let i = 0; i < nodes.length; i++) {
frontMatter[field].push(
richTextNodes(nodes[i])
);
}
}
// arrays
else {
if (!fieldContent.length) {
frontMatter[field] = fieldContent;
} else {
frontMatter[field] = [];
for (
let i = 0;
i < fieldContent.length;
i++
) {
const arrayNode = fieldContent[i];
switch (typeof arrayNode) {
case 'object': {
let arrayObject = {};
switch (arrayNode.sys.type) {
case 'Asset':
arrayObject = getAssetFields(
arrayNode
);
frontMatter[field].push(
arrayObject
);
break;
case 'Entry':
arrayObject = getEntryFields(
arrayNode
);
frontMatter[field].push(
arrayObject
);
break;
default:
frontMatter[field].push(
arrayNode
);
break;
}
break;
}
default:
frontMatter[field].push(
arrayNode
);
break;
}
}
}
}
break;
default:
frontMatter[field] = item.fields[field];
break;
}
}
let mainContent = null;

@@ -399,0 +288,0 @@ if (item.fields[contentSettings.mainContent]) {

2

package.json
{
"name": "contentful-hugo",
"version": "1.5.1",
"version": "1.5.2",
"description": "Node module that pulls data from Contentful and turns it into markdown files for Hugo. Can be used with other Static Site Generators, but has some Hugo specific features.",

@@ -5,0 +5,0 @@ "main": "index.js",

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