@@ -3,9 +3,12 @@ import { useStaticQuery, graphql } from "gatsby"
33import { Tab , Tabs , TabList , TabPanel } from 'react-tabs' ;
44import 'react-tabs/style/react-tabs.css' ;
55
6+ const PREFIX = 23
67export default function ScannerExamples ( props ) {
78
8- const scanner = 'nmap' ;
9+ console . log ( props . scanner ) ;
10+
11+ const scanner = props . scanner . substring ( PREFIX ) ;
912 const query = graphql `
1013 query {
1114 examples: allFile(filter: {base: {regex: "/^(findings|scan).yaml/"}, extension: {eq: "yaml"}}) {
@@ -25,43 +28,36 @@ export default function ScannerExamples(props) {
2528 }
2629 }` ;
2730 const data = useStaticQuery ( query ) ;
28- console . log ( "Results for query" ) ;
29- console . log ( data ) ;
3031 const targets = [ ] ;
31- const examples = [ ] ;
32+ const examples = [ ] ;
3233
3334 const length = data . examples . edges . length
3435 let i ;
3536 for ( i = 0 ; i < length ; i ++ ) {
3637 const edge = data . examples . edges [ i ] ;
3738 const node = data . examples . nodes [ i ] ;
38- console . log ( edge . node . relativeDirectory )
3939 if ( edge . node . relativeDirectory . includes ( scanner ) ) {
4040 const target = data . examples . nodes [ i ] . fields . scanTarget
41- if ( ! targets . includes ( target ) ) {
41+ if ( ! targets . includes ( target ) )
4242 targets . push ( target ) ;
43- examples . push ( node ) ;
44- }
43+ examples . push ( node ) ;
4544 }
4645 }
4746
48- console . log ( targets ) ;
49- console . log ( examples ) ;
50-
5147 return (
5248 < div className = "container-fluid" >
5349 < h2 className = "title" > Examples</ h2 >
54-
5550 < Tabs >
5651 < TabList >
5752 { targets . map ( target => ( < Tab key = { target } > { target } </ Tab > ) ) }
5853 </ TabList >
5954 { targets . map ( target => ( < TabPanel key = { target } >
60- < Tabs > < TabList >
61- { examples . reverse ( ) . filter ( example => example . fields . scanTarget === target ) . map ( ( example , index ) => (
62- < Tab key = { index } > { example . fields . fileName } </ Tab >
63- ) ) }
64- </ TabList >
55+ < Tabs >
56+ < TabList >
57+ { examples . filter ( example => example . fields . scanTarget === target ) . map ( ( example , index ) => (
58+ < Tab key = { index } > { example . fields . fileName } </ Tab >
59+ ) ) }
60+ </ TabList >
6561
6662 { examples . filter ( example => example . fields . scanTarget === target ) . map ( ( example , index ) => (
6763 < TabPanel key = { index } >
0 commit comments