@@ -54,7 +54,9 @@ exports.createPages = ({ graphql, actions }) => {
5454 }
5555 }
5656 persistenceProvider: allMarkdownRemark(
57- filter: { fileAbsolutePath: { regex: "/integrations/persistence-provider/" } }
57+ filter: {
58+ fileAbsolutePath: { regex: "/integrations/persistence-provider/" }
59+ }
5860 ) {
5961 edges {
6062 node {
@@ -68,15 +70,15 @@ exports.createPages = ({ graphql, actions }) => {
6870 }
6971 }
7072 }
71- ` ) . then ( result => {
73+ ` ) . then ( ( result ) => {
7274 result . data . getStarted . edges . forEach ( ( { node } ) => {
7375 const component = path . resolve ( "src/templates/getStarted.js" ) ;
7476 createPage ( {
7577 path : node . frontmatter . path ,
7678 component,
7779 context : {
78- id : node . id
79- }
80+ id : node . id ,
81+ } ,
8082 } ) ;
8183 } ) ;
8284 result . data . docs . edges . forEach ( ( { node } ) => {
@@ -85,28 +87,48 @@ exports.createPages = ({ graphql, actions }) => {
8587 path : node . frontmatter . path ,
8688 component,
8789 context : {
88- id : node . id
89- }
90+ id : node . id ,
91+ } ,
9092 } ) ;
9193 } ) ;
9294 result . data . scanner . edges . forEach ( ( { node } ) => {
95+ console . log ( node . frontmatter ) ;
9396 const component = path . resolve ( "src/templates/integration.js" ) ;
97+
98+ let componentName = "" ;
99+ if ( node . frontmatter . path ) {
100+ // The path consists normally like "scanners/nmap" or "hook/persistence-elastic"
101+ componentName = node . frontmatter . path . split ( "/" ) [ 1 ] ;
102+ }
103+
94104 createPage ( {
95105 path : `integrations/${ node . frontmatter . path } ` ,
96106 component,
97107 context : {
98- id : node . id
99- }
108+ id : node . id ,
109+ exampleFilter : `/${ componentName } /examples/` ,
110+ } ,
100111 } ) ;
101112 } ) ;
102113 result . data . persistenceProvider . edges . forEach ( ( { node } ) => {
103114 const component = path . resolve ( "src/templates/integration.js" ) ;
115+
116+ let componentName = "" ;
117+ if ( node . frontmatter . path ) {
118+ // The path consists normally like "scanners/nmap" or "hook/persistence-elastic"
119+ componentName = node . frontmatter . path . split ( "/" ) [ 1 ] ;
120+ }
121+
122+ console . log ( "filter" ) ;
123+ console . log ( `/${ componentName } /examples/` ) ;
124+
104125 createPage ( {
105- path :`integrations/${ node . frontmatter . path } ` ,
126+ path : `integrations/${ node . frontmatter . path } ` ,
106127 component,
107128 context : {
108- id : node . id
109- }
129+ id : node . id ,
130+ exampleFilter : `/${ componentName } /examples/` ,
131+ } ,
110132 } ) ;
111133 } ) ;
112134 resolve ( ) ;
@@ -118,11 +140,18 @@ exports.createPages = ({ graphql, actions }) => {
118140exports . onCreateNode = ( { node, actions } ) => {
119141 const { createNodeField } = actions ;
120142
121- if ( node . internal . type === `File` && ( node . base === `scan.yaml` || node . base === `findings.yaml` ) ) {
143+ if (
144+ node . internal . type === `File` &&
145+ ( node . base === `scan.yaml` || node . base === `findings.yaml` )
146+ ) {
122147 fs . readFile ( node . absolutePath , undefined , ( _err , buf ) => {
123148 createNodeField ( { node, name : `content` , value : buf . toString ( ) } ) ;
124149 } ) ;
125150 createNodeField ( { node, name : `fileName` , value : node . base } ) ;
126- createNodeField ( { node, name : `scanTarget` , value : node . relativeDirectory . split ( '/examples/' ) [ 1 ] } ) ;
151+ createNodeField ( {
152+ node,
153+ name : `scanTarget` ,
154+ value : node . relativeDirectory . split ( "/examples/" ) [ 1 ] ,
155+ } ) ;
127156 }
128- }
157+ } ;
0 commit comments