diff --git a/docs/contributing/style-guide.md b/docs/contributing/style-guide.md index ea343e3780..9f9aa49788 100644 --- a/docs/contributing/style-guide.md +++ b/docs/contributing/style-guide.md @@ -439,6 +439,39 @@ _sourceCategory=reinvent/travel/checkout For a full list of options, see [Docusaurus Code Blocks](https://docusaurus.io/docs/markdown-features/code-blocks). +### Import GitHub repo file + +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. + +This code references a json script file: + + + + + +JSON code snippet from GitHub + + + + +```json reference +https://github.com/SumoLogic/sumologic-documentation/blob/main/static/files/c2c/1password/example.json +``` + + + + +Optionally, you can: +* 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`. +* Add a title to the code block, such as `json reference title="Hello"`. + +You'll see this used in our [C2C source docs](/docs/send-data/hosted-collectors/cloud-to-cloud-integration-framework). ## Collapsible text blocks diff --git a/docusaurus.config.js b/docusaurus.config.js index 973d867752..bcd0dc3ab8 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -105,6 +105,7 @@ module.exports = { ], plugins: [ 'docusaurus-plugin-sass', + //Embed code file from GitHub repo '@saucelabs/theme-github-codeblock', ['@docusaurus/plugin-google-tag-manager', { diff --git a/static/img/contributing/json-ref-codeblock.png b/static/img/contributing/json-ref-codeblock.png new file mode 100644 index 0000000000..8e60ef294e Binary files /dev/null and b/static/img/contributing/json-ref-codeblock.png differ