Skip to content

Commit

Permalink
feat(*): first release
Browse files Browse the repository at this point in the history
  • Loading branch information
elboman committed May 12, 2018
0 parents commit 544cf9b
Show file tree
Hide file tree
Showing 6 changed files with 2,463 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
node_modules
/gatsby-node.js
3 changes: 3 additions & 0 deletions .npmignore
@@ -0,0 +1,3 @@
node_modules
src
yarn.lock
1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
// noop
29 changes: 29 additions & 0 deletions package.json
@@ -0,0 +1,29 @@
{
"name": "gatsby-remark-source-name",
"version": "1.0.0",
"description": "Add a custom sourceName field to remark nodes",
"main": "index.js",
"repository": "https://www.github.com/elboman/gatsby-remark-source-name",
"author": "Marco Botto",
"license": "MIT",
"private": false,
"keywords": [
"gatsby",
"gatsby-plugin",
"remark",
"source",
"name",
"sourceName"
],
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"cross-env": "^5.1.5",
"standard-version": "^4.3.0"
},
"scripts": {
"build": "cross-env BABEL_ENV=production babel src --out-dir .",
"prepublishOnly": "yarn build",
"release": "standard-version"
}
}
16 changes: 16 additions & 0 deletions src/gatsby-node.js
@@ -0,0 +1,16 @@
exports.onCreateNode = ({ node, getNode, boundActionCreators }) => {
const { createNodeField } = boundActionCreators;

// We only care about MarkdownRemark content.
if (node.internal.type !== 'MarkdownRemark') {
return;
}

const fileNode = getNode(node.parent);

createNodeField({
node,
name: 'sourceName',
value: fileNode.sourceInstanceName,
});
};

0 comments on commit 544cf9b

Please sign in to comment.