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

gatsby-transformer-javascript-frontmatter

Package Overview
Dependencies
Maintainers
1
Versions
310
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-transformer-javascript-frontmatter - npm Package Compare versions

Comparing version 1.1.0-alpha.067e672c to 1.1.0-alpha.2cbec6d6

74

gatsby-node.js

@@ -19,9 +19,9 @@ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");

getNode,
boundActionCreators,
actions,
loadNodeContent
}) {
const createNode = boundActionCreators.createNode,
createParentChildLink = boundActionCreators.createParentChildLink; // This only processes javascript files.
const createNode = actions.createNode,
createParentChildLink = actions.createParentChildLink; // This only processes javascript & jsx files.
if (node.internal.mediaType !== `application/javascript`) {
if (node.internal.mediaType !== `application/javascript` && node.internal.mediaType !== `text/jsx`) {
return;

@@ -36,3 +36,3 @@ }

};
let exportsData, frontmatter;
let exportsData, frontmatter, error;

@@ -64,2 +64,3 @@ try {

frontmatter = {};
error = false;
traverse(ast, {

@@ -87,40 +88,41 @@ AssignmentExpression: function AssignmentExpression(astPath) {

});
exportsData = Object.assign({}, frontmatter, {
error: false
});
} catch (e) {
// stick the error on the query so the user can
// react to an error as they see fit
exportsData = Object.assign({}, 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 {
const objStr = JSON.stringify(node);
const contentDigest = crypto.createHash(`md5`).update(objStr).digest(`hex`);
const nodeData = {
id: `${node.id} >>> JavascriptFrontmatter`,
children: [],
parent: node.id,
node: Object.assign({}, node),
internal: {
contentDigest,
type: `JavascriptFrontmatter`
// only create node if frontmatter is not empty
if (!_.isEmpty(frontmatter)) {
exportsData = Object.assign({}, frontmatter, {
error: error
});
const objStr = JSON.stringify(node);
const contentDigest = crypto.createHash(`md5`).update(objStr).digest(`hex`);
const nodeData = {
id: `${node.id} >>> JavascriptFrontmatter`,
children: [],
parent: node.id,
node: Object.assign({}, node),
internal: {
contentDigest,
type: `JavascriptFrontmatter`
}
};
nodeData.frontmatter = Object.assign({}, exportsData);
if (node.internal.type === `File`) {
nodeData.fileAbsolutePath = node.absolutePath;
}
};
nodeData.frontmatter = Object.assign({}, exportsData);
if (node.internal.type === `File`) {
nodeData.fileAbsolutePath = node.absolutePath;
createNode(nodeData);
createParentChildLink({
parent: node,
child: nodeData
});
}
createNode(nodeData);
createParentChildLink({
parent: node,
child: nodeData
});
}

@@ -127,0 +129,0 @@ });

{
"name": "gatsby-transformer-javascript-frontmatter",
"description": "Gatsby transformer plugin for JavaScript to extract exports.frontmatter statically.",
"version": "1.1.0-alpha.067e672c",
"version": "1.1.0-alpha.2cbec6d6",
"author": "Jacob Bolda <me@jacobbolda.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {

@@ -20,3 +17,2 @@ "babel-runtime": "^6.26.0",

},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-javascript-frontmatter#readme",
"keywords": [

@@ -28,6 +24,3 @@ "gatsby",

"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby.git"
},
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-javascript-frontmatter",
"scripts": {

@@ -34,0 +27,0 @@ "build": "babel src --out-dir . --ignore __tests__",

@@ -7,3 +7,3 @@ # gatsby-transformer-javascript-frontmatter

`npm install --save gatsby-transformer-frontmatter`
`npm install --save gatsby-transformer-javascript-frontmatter`

@@ -10,0 +10,0 @@ ## How to use

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