{"_id":"@ekline/starlight-contextual-menu","_rev":"2-9bb211d2b420954e3ad89a122f0d259d","name":"@ekline/starlight-contextual-menu","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@ekline/starlight-contextual-menu","version":"0.2.0","keywords":["astro","starlight","contextual-menu"],"author":{"url":"fork of Corsfix","name":"Ekline"},"license":"MIT","_id":"@ekline/starlight-contextual-menu@0.2.0","maintainers":[{"name":"ekline","email":"puneet@ekline.io"}],"homepage":"https://github.com/ekline-io/starlight-contextual-menu#readme","bugs":{"url":"https://github.com/ekline-io/starlight-contextual-menu/issues"},"dist":{"shasum":"79379873b21f24240e3ca2e463b7e936fb883469","tarball":"https://registry.npmjs.org/@ekline/starlight-contextual-menu/-/starlight-contextual-menu-0.2.0.tgz","fileCount":6,"integrity":"sha512-/9vQFNMs4DxzJ8b7gGo8QL4sce54U7Kp41SqXmyV8lsK0ph3D/9Zw+e30ij8iQBxCcHS5yLPnLdHyZxNZRZDPg==","signatures":[{"sig":"MEYCIQCxe6COdsZVxc4s/wpoHz8z1Rd1V1p4wT3R0HSjyyKdagIhANxEOvy/cPEbWntvmH/ZqErWY0pdctltqDLEpMcG93uW","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24289},"main":"index.js","type":"module","types":"index.d.ts","gitHead":"7bf75c8b9ceea3779adbf63656555f95350624d7","_npmUser":{"name":"ekline","email":"puneet@ekline.io"},"repository":{"url":"git+https://github.com/ekline-io/starlight-contextual-menu.git","type":"git","directory":"packages/starlight-contextual-menu"},"_npmVersion":"10.9.4","description":"Add a contextual (Copy / View / Open in Claude / ChatGPT) menu to your Starlight documentation. Ekline fork.","directories":{},"_nodeVersion":"22.21.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@astrojs/starlight":"^0.39.0"},"peerDependencies":{"astro":"^5.0.0 || ^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/starlight-contextual-menu_0.2.0_1778714358349_0.9170738111660564","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@ekline/starlight-contextual-menu","version":"0.3.0","description":"Add a contextual (Copy / View / Open in Claude / ChatGPT) menu to your Starlight documentation. Ekline fork.","license":"MIT","main":"index.js","types":"index.d.ts","keywords":["astro","starlight","contextual-menu"],"author":{"name":"Ekline","url":"fork of Corsfix"},"repository":{"type":"git","url":"git+https://github.com/ekline-io/starlight-contextual-menu.git","directory":"packages/starlight-contextual-menu"},"publishConfig":{"access":"public"},"type":"module","devDependencies":{"@astrojs/starlight":"^0.39.0"},"peerDependencies":{"astro":"^5.0.0 || ^6.0.0"},"_id":"@ekline/starlight-contextual-menu@0.3.0","gitHead":"dc3f757db7f8db9793c41d554b9da8773434794b","bugs":{"url":"https://github.com/ekline-io/starlight-contextual-menu/issues"},"homepage":"https://github.com/ekline-io/starlight-contextual-menu#readme","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-Qe792OU5fYl+jucbcDqzqHnFYZhpO1ksP30P/nqF2Az25Je1hZocrVlNqWCZnd52fJPwyOcKcHkY7NY8be1Veg==","shasum":"2dcfcc390a5ca9645c816e08bdfda4dd1f46a710","tarball":"https://registry.npmjs.org/@ekline/starlight-contextual-menu/-/starlight-contextual-menu-0.3.0.tgz","fileCount":7,"unpackedSize":28661,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQChxhEEcw2Qi84KvIIGppzZtqzCT9/vACTcase9DSq62wIhAMBPAVFp5E/aozpfiKsM2YXb0BSx5DuYIwkPOBIB8up0"}]},"_npmUser":{"name":"ekline","email":"puneet@ekline.io"},"directories":{},"maintainers":[{"name":"ekline","email":"puneet@ekline.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/starlight-contextual-menu_0.3.0_1778716812655_0.9760884011510391"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-13T23:19:18.216Z","modified":"2026-05-14T00:00:13.008Z","0.2.0":"2026-05-13T23:19:18.506Z","0.3.0":"2026-05-14T00:00:12.889Z"},"bugs":{"url":"https://github.com/ekline-io/starlight-contextual-menu/issues"},"author":{"name":"Ekline","url":"fork of Corsfix"},"license":"MIT","homepage":"https://github.com/ekline-io/starlight-contextual-menu#readme","keywords":["astro","starlight","contextual-menu"],"repository":{"type":"git","url":"git+https://github.com/ekline-io/starlight-contextual-menu.git","directory":"packages/starlight-contextual-menu"},"description":"Add a contextual (Copy / View / Open in Claude / ChatGPT) menu to your Starlight documentation. Ekline fork.","maintainers":[{"name":"ekline","email":"puneet@ekline.io"}],"readme":"# @ekline/starlight-contextual-menu\n\n> **Ekline fork of [`starlight-contextual-menu`](https://github.com/corsfix/starlight-contextual-menu)** by Reynaldi Chernando (Corsfix).\n> Differences from upstream are listed under [What's different in this fork](#whats-different-in-this-fork).\n\nAdds a per-page contextual menu (Copy / View as Markdown / Open in Claude / Open in ChatGPT / …) next to the H1 on every Starlight docs page, plus a parallel `/<slug>.md` URL for every doc and a `<link rel=\"alternate\" type=\"text/markdown\">` component for AI/crawler discoverability.\n\n## Install\n\n```bash\nnpm i @ekline/starlight-contextual-menu\n```\n\n## Set up the menu\n\nIn your `astro.config.mjs`:\n\n```js\nimport { defineConfig } from \"astro/config\";\nimport starlight from \"@astrojs/starlight\";\nimport starlightContextualMenu from \"@ekline/starlight-contextual-menu\";\n\nexport default defineConfig({\n  integrations: [\n    starlight({\n      title: \"My Docs\",\n      plugins: [\n        starlightContextualMenu({\n          actions: [\"copy\", \"view\", \"claude\", \"chatgpt\"],\n        }),\n      ],\n    }),\n  ],\n});\n```\n\nThat alone gives you the per-page menu *and* the `/<slug>.md` routes for every Markdown/MDX entry in `src/content/docs/`.\n\n### Built-in actions\n\n| Key | What it does |\n|---|---|\n| `copy` | Fetch `<url>.md` and write it to the clipboard |\n| `view` | Open `<url>.md` in a new tab |\n| `chatgpt` | Open ChatGPT with a \"read this page\" prompt |\n| `claude` | Open Claude with a \"read this page\" prompt |\n| `lechat` | Open Mistral Le Chat with the same prompt |\n| `grok` | Open Grok with the same prompt |\n\n### Options\n\n| Option | Default | Notes |\n|---|---|---|\n| `actions` | `[\"copy\", \"view\"]` | Order in the array = order in the dropdown. First entry is also the primary button. |\n| `injectMarkdownRoutes` | `true` | Set to `false` if another integration already serves `/<slug>.md` routes. |\n| `hideMainActionLabel` | `false` | Hide the text on the primary button (icon-only). |\n\n## Set up the alternate-markdown `<link>` tag\n\nThe plugin ships a small Astro component, `MarkdownAlternate.astro`, that emits a `<link rel=\"alternate\" type=\"text/markdown\" href=\"…\">` for the current page's Markdown twin. AI crawlers (GPTBot, ClaudeBot, …) use the `rel=\"alternate\"` convention to discover non-HTML representations without having to guess URL shapes.\n\nAdd a Starlight `Head` override (`src/components/Head.astro` or similar):\n\n```astro\n---\nimport Default from \"@astrojs/starlight/components/Head.astro\";\nimport MarkdownAlternate from \"@ekline/starlight-contextual-menu/MarkdownAlternate.astro\";\n---\n\n<Default />\n<MarkdownAlternate />\n```\n\nThen point Starlight at it in `astro.config.mjs`:\n\n```js\nstarlight({\n  // …\n  components: {\n    Head: \"./src/components/Head.astro\",\n  },\n}),\n```\n\nThe component is **safe to render on every page**. It only emits the `<link>` when the current page actually has a Markdown twin (real `.md`/`.mdx` source under `src/content/docs/`). Virtual entries injected by other plugins (`starlight-openapi`'s `/api/**` pages, for instance) are filtered out automatically, so you won't ship `<link>`s that 404.\n\n## Set up content negotiation (Vercel-deployed sites)\n\nFor `curl -H \"Accept: text/markdown\" https://your-site/concepts/glossary/` to return Markdown from the canonical HTML URL, add this to `vercel.json` at the repository root:\n\n```json\n{\n  \"rewrites\": [\n    {\n      \"source\": \"/\",\n      \"has\": [\n        { \"type\": \"header\", \"key\": \"accept\", \"value\": \"text/markdown\" }\n      ],\n      \"destination\": \"/index.md\"\n    },\n    {\n      \"source\": \"/:path+/\",\n      \"has\": [\n        { \"type\": \"header\", \"key\": \"accept\", \"value\": \"text/markdown\" }\n      ],\n      \"destination\": \"/:path+.md\"\n    }\n  ]\n}\n```\n\nThis works at the Vercel edge — no Astro mode change, no per-request render. Browser requests (`Accept: text/html, …`) keep getting HTML; Markdown-only clients get the `.md`. Equivalent setups exist for Netlify (`_redirects`) and Cloudflare Pages (Workers).\n\n## What's different in this fork\n\n1. **Inlines `starlight-markdown`.** Upstream pulls in [`starlight-markdown`](https://github.com/reynaldichernando/starlight-markdown) as a peer dependency to register the markdown routes. We've inlined that logic (~25 LoC) so the install is self-contained — no second peer dep to track.\n\n2. **URL pattern is `/<slug>.md`** (not `/<slug>/index.md`). Aligns with the convention used by Anthropic, Vercel, and Next.js docs, where every HTML page has a sibling at the same URL with `.md` appended.\n\n3. **View-transitions safe.** Upstream only attaches the menu on `DOMContentLoaded`, which doesn't re-fire during Starlight's SPA-style navigation, so the menu disappears after the first navigation until you refresh. This fork also listens on `astro:page-load` and re-attaches idempotently on every page render.\n\n4. **`MarkdownAlternate.astro` component.** New in 0.3.0 — emits the `<link rel=\"alternate\" type=\"text/markdown\">` tag for pages that have a real Markdown twin, with the OpenAPI / virtual-entry filter built in.\n\n5. **Astro 6 supported.** Peer dep is `astro@^5 || ^6` (upstream is `^5` only).\n\n## Credit\n\nOriginal plugin and ongoing upstream maintenance by [Reynaldi Chernando / Corsfix](https://github.com/corsfix/starlight-contextual-menu) under MIT. The inlined `markdown-route.js` is adapted from `starlight-markdown@0.1.5` by the same author. Both retain their MIT copyright.\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}