Skip to content

Commit 81ed83c

Browse files
committed
Add style guidance for docusaurus-theme-github-codeblock
1 parent 798c3fc commit 81ed83c

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

docs/contributing/style-guide.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,39 @@ _sourceCategory=reinvent/travel/checkout
439439
440440
For a full list of options, see [Docusaurus Code Blocks](https://docusaurus.io/docs/markdown-features/code-blocks).
441441
442+
### Import GitHub repo file
443+
444+
To embed a code sample from a file in a GitHub repository, use `reference` in the code block with a link to the file. The code sample is embedded using the language with a link to the original file.
445+
446+
This code references a json script file:
447+
448+
<Tabs
449+
className="unique-tabs"
450+
defaultValue="Markdown"
451+
values={[
452+
{label: 'Markdown', value: 'Markdown'},
453+
{label: 'Result', value: 'Result'},
454+
]}>
455+
456+
<TabItem value="Markdown">
457+
458+
<img src={useBaseUrl('img/contributing/json-ref-codeblock.png')} alt="JSON code snippet from GitHub" style={{border: '1px solid gray'}} width="700"/>
459+
460+
</TabItem>
461+
<TabItem value="Result">
462+
463+
```json reference
464+
https://github.com/SumoLogic/sumologic-documentation/blob/main/static/files/c2c/1password/example.json
465+
```
466+
467+
</TabItem>
468+
</Tabs>
469+
470+
Optionally, you can:
471+
* Reference a specific range of code lines by appending `#L` with the line number or numbers at the end of the URL. For example, `https://github.com/SumoLogic/sumologic-documentation/blob/main/static/files/c2c/1password/example.json#L4-L5`.
472+
* Add a title to the code block, such as `json reference title="Hello"`.
473+
474+
You'll see this used in our [C2C source docs](/docs/send-data/hosted-collectors/cloud-to-cloud-integration-framework).
442475
443476
## Collapsible text blocks
444477

docusaurus.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ module.exports = {
105105
],
106106
plugins: [
107107
'docusaurus-plugin-sass',
108+
//Embed code file from GitHub repo
108109
'@saucelabs/theme-github-codeblock',
109110
['@docusaurus/plugin-google-tag-manager',
110111
{
40.8 KB
Loading

0 commit comments

Comments
 (0)