Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 8ec6b25

Browse files
authored
Merge pull request #17 from secureCodeBox/code-higlighting
Add Highlighting to Code Blocks
2 parents 3db23ed + 6b634de commit 8ec6b25

8 files changed

Lines changed: 325 additions & 137 deletions

File tree

gatsby-config.js

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ module.exports = {
88
siteMetadata: {
99
title: `secureCodeBox`,
1010
company: `iteratec GmbH`,
11-
description: '',
11+
description: "",
1212
// siteUrl: '',
1313
contact: {
14-
phone: '+49 89 614551-0',
15-
email: 'security@iteratec.com',
14+
phone: "+49 89 614551-0",
15+
email: "security@iteratec.com",
1616
},
1717
// TODO: replace links with actual pages here and link the correct reference in Menu.js
1818
menuLinks: [
1919
{
20-
name: 'Get Started',
20+
name: "Get Started",
2121
external: true,
2222
// link: '/getStarted',
23-
link: 'https://github.com/secureCodeBox/secureCodeBox-v2-alpha',
23+
link: "https://github.com/secureCodeBox/secureCodeBox-v2-alpha",
2424
},
2525
{
26-
name: 'Docs',
26+
name: "Docs",
2727
external: true,
2828
// link: '/docs',
2929
link:
30-
'https://github.com/secureCodeBox/secureCodeBox-v2-alpha/blob/master/docs/index.md',
30+
"https://github.com/secureCodeBox/secureCodeBox-v2-alpha/blob/master/docs/index.md",
3131
},
3232
{
33-
name: 'Integrations',
33+
name: "Integrations",
3434
external: false,
35-
link: '/integrations',
35+
link: "/integrations",
3636
},
3737
],
3838
},
@@ -48,6 +48,21 @@ module.exports = {
4848
maxDepth: 6,
4949
},
5050
excerpt_separator: `<!-- end -->`,
51+
plugins: [
52+
{
53+
resolve: `gatsby-remark-highlight-code`,
54+
options: {
55+
terminal: "carbon",
56+
theme: "cobalt",
57+
},
58+
},
59+
{
60+
resolve: `gatsby-remark-autolink-headers`,
61+
options: {
62+
icon: `<svg aria-hidden="true" height="20" version="1.1" viewBox="0 0 16 16" width="20"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>`,
63+
},
64+
},
65+
],
5166
},
5267
},
5368
{
@@ -69,29 +84,29 @@ module.exports = {
6984
{
7085
resolve: `gatsby-source-filesystem`,
7186
options: {
72-
name: 'src',
87+
name: "src",
7388
path: `${__dirname}/src/`,
7489
},
7590
},
7691
{
77-
resolve: 'gatsby-source-filesystem',
92+
resolve: "gatsby-source-filesystem",
7893
options: {
7994
path: `${__dirname}/src/pages`,
80-
name: 'pages',
95+
name: "pages",
8196
},
8297
},
8398
{
84-
resolve: 'gatsby-source-filesystem',
99+
resolve: "gatsby-source-filesystem",
85100
options: {
86101
path: `${__dirname}/src/data`,
87-
name: 'data',
102+
name: "data",
88103
},
89104
},
90105
{
91-
resolve: 'gatsby-source-filesystem',
106+
resolve: "gatsby-source-filesystem",
92107
options: {
93108
path: `${__dirname}/src/images`,
94-
name: 'images',
109+
name: "images",
95110
},
96111
},
97112
{
@@ -108,14 +123,14 @@ module.exports = {
108123
options: {
109124
name: `scanners`,
110125
path: `${__dirname}/.cache/gatsby-source-git/secureCodeBox-v2-alpha/scanners`,
111-
}
126+
},
112127
},
113128
{
114129
resolve: `gatsby-source-filesystem`,
115130
options: {
116131
name: `hooks`,
117132
path: `${__dirname}/.cache/gatsby-source-git/secureCodeBox-v2-alpha/hooks`,
118-
}
119-
}
133+
},
134+
},
120135
],
121136
};

gatsby-node.js

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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 }) => {
118136
exports.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

Comments
 (0)