File tree Expand file tree Collapse file tree 4 files changed +71
-0
lines changed Expand file tree Collapse file tree 4 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ node_modules /
Original file line number Diff line number Diff line change
1
+ // lol
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " gatsby-transformer-yaml-netlify" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Gatsby transformer plugin for yaml that is netlify compatible" ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "build" : " babel src --out-dir . --ignore __tests__" ,
8
+ "watch" : " babel -w src --out-dir . --ignore __tests__" ,
9
+ "prepublish" : " cross-env NODE_ENV=production npm run build"
10
+ },
11
+ "repository" : {
12
+ "type" : " git" ,
13
+ "url" : " git+https://github.com/computerlab.io/gatsby-transformer-yaml-netlify.git"
14
+ },
15
+ "keywords" : [
16
+ " gatsby" ,
17
+ " gatsby-plugin" ,
18
+ " yaml" ,
19
+ " netlify"
20
+ ],
21
+ "author" :
" Robert C Jensen <[email protected] >" ,
22
+ "license" : " BSD-2-Clause" ,
23
+ "bugs" : {
24
+ "url" : " https://github.com/computerlab.io/gatsby-transformer-yaml-netlify/issues"
25
+ },
26
+ "homepage" : " https://github.com/computerlab.io/gatsby-transformer-yaml-netlify#readme" ,
27
+ "devDependencies" : {
28
+ "babel-cli" : " ^6.26.0" ,
29
+ "cross-env" : " ^5.0.5"
30
+ },
31
+ "dependencies" : {
32
+ "babel-runtime" : " ^6.26.0" ,
33
+ "js-yaml" : " ^3.10.0" ,
34
+ "lodash" : " ^4.17.4"
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+ const crypto = require ( 'crypto' ) ;
2
+ const jsYaml = require ( 'js-yaml' ) ;
3
+ const _ = require ( `lodash` ) ;
4
+
5
+ async function onCreateNode ( { node, boundActionCreators, loadNodeContent } ) {
6
+ const { createNode, createParentChildLink } = boundActionCreators
7
+
8
+ if ( node . internal . mediaType !== 'text/yaml' ) {
9
+ return ;
10
+ }
11
+
12
+ const obj = jsYaml . load ( await loadNodeContent ( node ) ) ;
13
+ const contentDigest = crypto
14
+ . createHash ( `md5` )
15
+ . update ( JSON . stringify ( obj ) )
16
+ . digest ( `hex` ) ;
17
+ const yamlNode = {
18
+ ...obj ,
19
+ id : obj . id ? obj . id : `${ node . id } >>> YAML` ,
20
+ children : [ ] ,
21
+ parent : node . id ,
22
+ internal : {
23
+ contentDigest,
24
+ // Note `node.dir` vs `node.name`
25
+ type : _ . upperFirst ( _ . camelCase ( `${ node . dir } Yaml` ) ) ,
26
+ } ,
27
+ } ;
28
+
29
+ createNode ( yamlNode )
30
+ createParentChildLink ( { parent : node , child : yamlNode } )
31
+ }
32
+
33
+ exports . onCreateNode = onCreateNode ;
You can’t perform that action at this time.
0 commit comments