|
| 1 | +--- |
| 2 | +title: "Contextual menu" |
| 3 | +description: "Add one-click AI integrations to your docs" |
| 4 | +icon: "square-menu" |
| 5 | +--- |
| 6 | + |
| 7 | +import { PreviewButton } from "/snippets/previewbutton.jsx" |
| 8 | + |
| 9 | +The contextual menu provides quick access to AI-optimized content and direct integrations with popular AI tools. When users select the contextual menu on any page, they can copy content as context for AI tools or open conversations in ChatGPT, Claude, Perplexity, or a custom tool of your choice with your documentation already loaded as context. |
| 10 | + |
| 11 | +## Menu options |
| 12 | + |
| 13 | +- **Copy page**: Copies the current page as Markdown for pasting as context into AI tools. |
| 14 | +- **View as Markdown**: Opens the current page as Markdown. |
| 15 | +- **Open in ChatGPT**: Creates a ChatGPT conversation with the current page as context. |
| 16 | +- **Open in Claude**: Creates a Claude conversation with the current page as context. |
| 17 | +- **Open in Perplexity**: Creates a Perplexity conversation with the current page as context. |
| 18 | +- **[Your custom options](#adding-custom-options)**: Add your own options to the menu. |
| 19 | + |
| 20 | +<Frame> |
| 21 | + <img |
| 22 | + src="/images/contextual-menu/contextual-menu.png" |
| 23 | + alt="The expanded contextual menu showing the Copy page, View as Markdown, Open in ChatGPT, and Open in Claude menu items." |
| 24 | + /> |
| 25 | +</Frame> |
| 26 | + |
| 27 | +## Enabling the contextual menu |
| 28 | + |
| 29 | +Add the `contextual` field to your `docs.json` file and specify which options you want to include. |
| 30 | + |
| 31 | +```json |
| 32 | +{ |
| 33 | + "contextual": { |
| 34 | + "options": [ |
| 35 | + "copy", |
| 36 | + "view", |
| 37 | + "chatgpt", |
| 38 | + "claude", |
| 39 | + "perplexity" |
| 40 | + ] |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +## Adding custom options |
| 46 | + |
| 47 | +Create custom options in the contextual menu by adding an object to the `options` array. Each custom option requires these properties: |
| 48 | + |
| 49 | +<ResponseField name="title" type="string" required> |
| 50 | + The title of the option. |
| 51 | +</ResponseField> |
| 52 | + |
| 53 | +<ResponseField name="description" type="string" required> |
| 54 | + The description of the option. Displayed beneath the title when the contextual menu is expanded. |
| 55 | +</ResponseField> |
| 56 | + |
| 57 | +<ResponseField name="icon" type="string" required> |
| 58 | + The icon of the option. Accepts any icon from the [Icons](/components/icons) collection. |
| 59 | +</ResponseField> |
| 60 | + |
| 61 | +<ResponseField name="href" type="string | object" required> |
| 62 | + The href of the option. Use a string for simple links or an object for dynamic links with query parameters. |
| 63 | + |
| 64 | + <Expandable title="href object"> |
| 65 | + <ResponseField name="base" type="string" required> |
| 66 | + The base URL for the option. |
| 67 | + </ResponseField> |
| 68 | + |
| 69 | + <ResponseField name="query" type="object" required> |
| 70 | + The query parameters for the option. |
| 71 | + |
| 72 | + <Expandable title="query object"> |
| 73 | + <ResponseField name="key" type="string" required> |
| 74 | + The query parameter key. |
| 75 | + </ResponseField> |
| 76 | + |
| 77 | + <ResponseField name="value" type="string" required> |
| 78 | + The query parameter value. Use `$page` to insert the current page content in Markdown or `$path` to insert the current page path. |
| 79 | + </ResponseField> |
| 80 | + </Expandable> |
| 81 | + </ResponseField> |
| 82 | + </Expandable> |
| 83 | +</ResponseField> |
| 84 | + |
| 85 | +Example custom option: |
| 86 | + |
| 87 | +```json {8-21} |
| 88 | +"contextual": { |
| 89 | + "options": [ |
| 90 | + "copy", |
| 91 | + "view", |
| 92 | + "chatgpt", |
| 93 | + "claude", |
| 94 | + "perplexity", |
| 95 | + { |
| 96 | + "title": "Ask Gemini", |
| 97 | + "description": "Ask Google Gemini about the current page", |
| 98 | + "icon": "sparkle", |
| 99 | + "href": { |
| 100 | + "base": "https://gemini.google.com/app", |
| 101 | + "query": [ |
| 102 | + { |
| 103 | + "key": "q", |
| 104 | + "value": "Ask question about https://mintlify.com/docs$path.md" |
| 105 | + } |
| 106 | + ] |
| 107 | + } |
| 108 | + } |
| 109 | + ] |
| 110 | +} |
| 111 | +``` |
0 commit comments