gatsby-transformer-javascript-frontmatter
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -21,3 +21,3 @@ "use strict"; | ||
loadNodeContent = _ref.loadNodeContent; | ||
var createNode, createParentChildLink, code, options, exportsData, frontmatter, ast, parseData, objStr, contentDigest, nodeData; | ||
var createNode, createParentChildLink, code, options, exportsData, frontmatter, error, ast, parseData, objStr, contentDigest, nodeData; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
@@ -49,3 +49,3 @@ while (1) { | ||
}; | ||
exportsData = void 0, frontmatter = void 0; | ||
exportsData = void 0, frontmatter = void 0, error = void 0; | ||
@@ -81,2 +81,3 @@ try { | ||
frontmatter = {}; | ||
error = false; | ||
traverse(ast, { | ||
@@ -106,40 +107,42 @@ AssignmentExpression: function AssignmentExpression(astPath) { | ||
}); | ||
exportsData = (0, _extends3.default)({}, frontmatter, { | ||
error: false | ||
}); | ||
} catch (e) { | ||
// stick the error on the query so the user can | ||
// react to an error as they see fit | ||
exportsData = (0, _extends3.default)({}, frontmatter, { | ||
error: { | ||
err: true, | ||
code: e.code, | ||
message: e.message, | ||
stack: e.stack | ||
} | ||
}); | ||
error = { | ||
err: true, | ||
code: e.code, | ||
message: e.message, | ||
stack: e.stack | ||
}; | ||
} finally { | ||
objStr = JSON.stringify(node); | ||
contentDigest = crypto.createHash(`md5`).update(objStr).digest(`hex`); | ||
nodeData = { | ||
id: `${node.id} >>> JavascriptFrontmatter`, | ||
children: [], | ||
parent: node.id, | ||
node: (0, _extends3.default)({}, node), | ||
internal: { | ||
contentDigest, | ||
type: `JavascriptFrontmatter` | ||
} | ||
}; | ||
// only create node if frontmatter is not empty | ||
if (!_.isEmpty(frontmatter)) { | ||
exportsData = (0, _extends3.default)({}, frontmatter, { | ||
error: error | ||
}); | ||
nodeData.frontmatter = (0, _extends3.default)({}, exportsData); | ||
objStr = JSON.stringify(node); | ||
contentDigest = crypto.createHash(`md5`).update(objStr).digest(`hex`); | ||
nodeData = { | ||
id: `${node.id} >>> JavascriptFrontmatter`, | ||
children: [], | ||
parent: node.id, | ||
node: (0, _extends3.default)({}, node), | ||
internal: { | ||
contentDigest, | ||
type: `JavascriptFrontmatter` | ||
} | ||
}; | ||
if (node.internal.type === `File`) { | ||
nodeData.fileAbsolutePath = node.absolutePath; | ||
nodeData.frontmatter = (0, _extends3.default)({}, exportsData); | ||
if (node.internal.type === `File`) { | ||
nodeData.fileAbsolutePath = node.absolutePath; | ||
} | ||
createNode(nodeData); | ||
createParentChildLink({ parent: node, child: nodeData }); | ||
} | ||
createNode(nodeData); | ||
createParentChildLink({ parent: node, child: nodeData }); | ||
} | ||
@@ -146,0 +149,0 @@ |
{ | ||
"name": "gatsby-transformer-javascript-frontmatter", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Gatsby transformer plugin for JavaScript to extract exports.frontmatter statically.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9186
136