Last updated

copyCodeSnippet

Usage

Use the copyCodeSnippet section to display the copy button in all Markdown code blocks in the portal. The copy button provides a quick and practical way to copy the whole code block to the clipboard in a single action (tap or click).

Add the copyCodeSnippet section to the top level of the siteConfig.yaml file and configure supported options inside it.

Note

The copy button is a global feature that affects all pages in the portal (cannot be configured per-page in the front matter). It is enabled by default starting from the 1.1.0-beta.55 version. To disable it, set enable: false in the copyCodeSnippet section.

Options

OptionDescription
enableWhen set to true, the copy button is displayed in the upper right corner of all Markdown code blocks. The default value is true.
buttonTextSets the text displayed on the button. The default value is Copy.
tooltipTextSets the text displayed in the tooltip when hovering over the button. The default value is Copy the code snippet.
toasterTextSets the text displayed in the notification that appears after successfully copying the code sample. The default value is Copied.
toasterDurationSpecifies how long the notification is visible (in milliseconds). The default value is 1500.

Examples

  1. Default settings
  2. Custom settings
seo:
  title: Example Developer Portal
  description: Learn how to work with Example APIs
copyCodeSnippet:
  enable: true
  buttonText: Copy
  tooltipText: Copy the code snippet
  toasterText: Copied
  toasterDuration: 1500