Skip to content

Commit 6e33365

Browse files
author
Kirill Bolotsky
committed
refactor(mdx): changed the way of processing inline code
Inline code is no more being handled by Prism, we are rendering it with MDXProvider and custom CodeInline component, similar to other mdx entities. Side: - fixed some mdx syntax innacuracies along with main changes
1 parent 8159ab3 commit 6e33365

File tree

9 files changed

+30
-24
lines changed

9 files changed

+30
-24
lines changed

gatsby-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const plugins = [
6868
resolve: 'gatsby-remark-prismjs',
6969
options: {
7070
showLineNumbers: true,
71+
noInlineHighlight: true,
7172
},
7273
},
7374
{

src/components/blocks/html-content/html-content.module.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,6 @@
111111
}
112112
}
113113
}
114-
:not(pre) code[class='language-text'] {
115-
background: $color-additional-3;
116-
padding: 0 5px !important; // to fight another important @ code.module
117-
color: $color-primary !important;
118-
display: inline-block;
119-
text-align: center;
120-
border-radius: 0;
121-
font-weight: normal;
122-
font-size: $font-size-code;
123-
line-height: $line-height-xs;
124-
}
125114
& > * + * {
126115
margin-top: 30px;
127116
}

src/components/shared/blockquote/blockquote.module.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ blockquote {
1212
p {
1313
margin: 0;
1414
}
15-
:not(pre) code[class='language-text'] {
16-
background: $color-additional-2 !important;
17-
line-height: 18px !important;
15+
span[class='code-inline'] {
16+
background-color: $color-additional-2;
1817
}
1918
}
2019

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.code-inline {
2+
background-color: $color-additional-3;
3+
padding: 0 5px;
4+
color: $color-primary;
5+
display: inline-block;
6+
text-align: center;
7+
border-radius: 0;
8+
font-weight: normal;
9+
font-size: $font-size-code;
10+
line-height: $line-height-xs;
11+
font-family: $font-family-secondary;
12+
}

src/components/shared/code/code.view.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as React from 'react';
2+
23
import styles from './code.module.scss';
4+
import './code-inline.scss';
35

46
export const Code = ({ children, noLineNumbers }) => {
57
return (
@@ -11,3 +13,7 @@ export const Code = ({ children, noLineNumbers }) => {
1113
/>
1214
);
1315
};
16+
17+
export const CodeInline = ({ children }) => (
18+
<span className="code-inline">{children}</span>
19+
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { Code } from './code.view';
1+
export { Code, CodeInline } from './code.view';
22
export { default as styles } from './code.module.scss';

src/components/templates/doc-page/doc-page-content/doc-page-content.view.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { HtmlContent } from 'components/blocks/html-content';
33
import Glossary from 'components/pages/doc-page/glossary';
44
import TableOfContents from 'components/pages/doc-page/table-of-contents';
55
import Blockquote from 'components/shared/blockquote';
6+
import { CodeInline } from 'components/shared/code';
67
import { CodeGroup } from 'components/shared/code-group';
78
import { HeadingLandmark } from 'components/shared/heading';
89
import LdScript from 'components/shared/ld-script';
@@ -20,6 +21,7 @@ const componentsForNativeReplacement = {
2021
Blockquote,
2122
LdScript,
2223
Glossary,
24+
inlineCode: CodeInline,
2325
};
2426

2527
const componentsForCustomReplacement = {

src/data/markdown/docs/01 guides/01 Getting started/03 Running k6.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ favourite editor, and save it as "script.js":
1414
import http from 'k6/http';
1515
import { sleep } from 'k6';
1616

17-
export default function() {
17+
export default function () {
1818
http.get('http://test.k6.io');
1919
sleep(1);
2020
}
@@ -78,7 +78,7 @@ your VUs, similar to the `main()` function in many other languages:
7878
<div class="code-group" data-props='{"labels": []}'>
7979

8080
```javascript
81-
export default function() {
81+
export default function () {
8282
// vu code: do things here...
8383
}
8484
```
@@ -112,7 +112,6 @@ import any other modules. This all has to be done from init-code.
112112
113113
Read more about the different [life cycle stages of a k6 test](/using-k6/test-life-cycle).
114114
115-
116115
## Using options
117116
118117
If you want to avoid having to type `--vus 10` and `--duration 30s` all the time, you can include
@@ -127,7 +126,7 @@ export let options = {
127126
vus: 10,
128127
duration: '30s',
129128
};
130-
export default function() {
129+
export default function () {
131130
http.get('http://test.k6.io');
132131
sleep(1);
133132
}
@@ -172,9 +171,9 @@ export let options = {
172171
],
173172
};
174173

175-
export default function() {
174+
export default function () {
176175
let res = http.get('https://httpbin.org/');
177-
check(res, { 'status was 200': r => r.status == 200 });
176+
check(res, { 'status was 200': (r) => r.status == 200 });
178177
sleep(1);
179178
}
180179
```
@@ -199,9 +198,7 @@ For running cloud tests from the CLI, you must first register a k6 Cloud account
199198
<div class="code-group" data-props='{"labels": ["Running a cloud test"]}'>
200199
201200
```shell
202-
203201
$ k6 cloud script.js
204-
205202
```
206203
207204
</div>

src/data/markdown/docs/01 guides/05 Testing Guides/02 Automated performance testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ k6 supports both local (`k6 run ...`) and cloud execution (`k6 cloud ...`) modes
144144

145145
If you decide to use the k6 Cloud service, either to stream results with local execution (`k6 run -o cloud ...`) or through cloud execution, you'll need to authenticate with k6 Cloud. The recommended way to do this is by setting the `K6_CLOUD_TOKEN` environment variable in your CI tool. Alternatively you can pass in your k6 Cloud token to `k6 login cloud` like so:
146146

147-
```sh
147+
```shell
148148
k6 login cloud -t <YOUR_K6_CLOUD_TOKEN>
149149
```
150150

0 commit comments

Comments
 (0)