@@ -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,44 @@ 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 } ) => {
9395 const component = path . resolve ( "src/templates/integration.js" ) ;
96+
97+ let componentName = "" ;
98+ if ( node . frontmatter . path ) {
99+ // The path consists normally like "scanners/nmap" or "hook/persistence-elastic"
100+ componentName = node . frontmatter . path . split ( "/" ) [ 1 ] ;
101+ }
102+
94103 createPage ( {
95104 path : `integrations/${ node . frontmatter . path } ` ,
96105 component,
97106 context : {
98- id : node . id
99- }
107+ id : node . id ,
108+ exampleFilter : `/${ componentName } /examples/` ,
109+ } ,
100110 } ) ;
101111 } ) ;
102112 result . data . persistenceProvider . edges . forEach ( ( { node } ) => {
103113 const component = path . resolve ( "src/templates/integration.js" ) ;
114+
115+ let componentName = "" ;
116+ if ( node . frontmatter . path ) {
117+ // The path consists normally like "scanners/nmap" or "hook/persistence-elastic"
118+ componentName = node . frontmatter . path . split ( "/" ) [ 1 ] ;
119+ }
120+
104121 createPage ( {
105- path :`integrations/${ node . frontmatter . path } ` ,
122+ path : `integrations/${ node . frontmatter . path } ` ,
106123 component,
107124 context : {
108- id : node . id
109- }
125+ id : node . id ,
126+ exampleFilter : `/${ componentName } /examples/` ,
127+ } ,
110128 } ) ;
111129 } ) ;
112130 resolve ( ) ;
@@ -118,11 +136,18 @@ exports.createPages = ({ graphql, actions }) => {
118136exports . onCreateNode = ( { node, actions } ) => {
119137 const { createNodeField } = actions ;
120138
121- if ( node . internal . type === `File` && ( node . base === `scan.yaml` || node . base === `findings.yaml` ) ) {
139+ if (
140+ node . internal . type === `File` &&
141+ ( node . base === `scan.yaml` || node . base === `findings.yaml` )
142+ ) {
122143 fs . readFile ( node . absolutePath , undefined , ( _err , buf ) => {
123144 createNodeField ( { node, name : `content` , value : buf . toString ( ) } ) ;
124145 } ) ;
125146 createNodeField ( { node, name : `fileName` , value : node . base } ) ;
126- createNodeField ( { node, name : `scanTarget` , value : node . relativeDirectory . split ( '/examples/' ) [ 1 ] } ) ;
147+ createNodeField ( {
148+ node,
149+ name : `scanTarget` ,
150+ value : node . relativeDirectory . split ( "/examples/" ) [ 1 ] ,
151+ } ) ;
127152 }
128- }
153+ } ;
0 commit comments