From 0bbbb7ceb496b87f84f78aac96b55ac76c633362 Mon Sep 17 00:00:00 2001 From: zedoraps Date: Thu, 4 Jun 2026 12:45:44 +0200 Subject: [PATCH 1/4] Add copy-as-Markdown action to documentation pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a copy-for-LLM button and "View page as markdown" / "Use in your agent" dropdown to every documentation page. The button copies the page's Markdown twin to the clipboard; the menu links open the same content for human or agent consumption. Decouple the per-page `.md` route from the `LLMS_TXT` env flag via a new plugin option, so the action works in normal dev and production builds. The site-wide `/llms.txt` and `/llms-full.txt` routes stay gated behind the flag. Add a shared `markdownPathForDocPath` / `markdownUrlForDocPath` helper so the per-page route, the copy URL in PageTitle, and link rewriting in entry-to-markdown agree on slug normalization (`*/index` → `*`). Move changelog topics behind an `import.meta.glob` loader so the per-page route survives fresh checkouts where the generated `sidebar-changelog.generated.ts` is absent. Assisted-by: Claude Opus 4.7 (Claude Code) --- astro.config.mjs | 24 +- src/components/PageTitle.astro | 708 +++++++++++++++++- .../starlight-llms-txt/changelog-topics.ts | 16 + .../starlight-llms-txt/entry-to-markdown.ts | 3 +- src/plugins/starlight-llms-txt/index.ts | 36 +- .../routes/page-markdown.ts | 32 +- .../starlight-llms-txt/sitemap-generator.ts | 7 +- src/plugins/starlight-llms-txt/types.ts | 9 + src/utils/llm-markdown-path.ts | 20 + 9 files changed, 802 insertions(+), 53 deletions(-) create mode 100644 src/plugins/starlight-llms-txt/changelog-topics.ts create mode 100644 src/utils/llm-markdown-path.ts diff --git a/astro.config.mjs b/astro.config.mjs index 00de01b0e..f20159a39 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -162,20 +162,16 @@ export default defineConfig({ }, }, plugins: [ - ...(llmsTxt - ? [ - starlightLlmsTxt({ - projectName: "Tenzir", - description: - "The low-code data pipeline solution for security teams", - perPageMarkdown: { - extensionStrategy: "replace", - }, - sitemapAlias: true, - preambles: true, - }), - ] - : []), + starlightLlmsTxt({ + llmsTxt, + projectName: "Tenzir", + description: "The low-code data pipeline solution for security teams", + perPageMarkdown: { + extensionStrategy: "replace", + }, + sitemapAlias: llmsTxt, + preambles: llmsTxt, + }), ...(checkLinks ? [ starlightLinksValidator({ diff --git a/src/components/PageTitle.astro b/src/components/PageTitle.astro index 9a9bd2c1e..cd60fe90a 100644 --- a/src/components/PageTitle.astro +++ b/src/components/PageTitle.astro @@ -1,6 +1,6 @@ --- -import type { Props } from "@astrojs/starlight/props"; import { pathWithBase } from "@utils/base"; +import { markdownPathForDocPath } from "@utils/llm-markdown-path"; import { formatSlug, getDocsMap } from "@utils/page-title"; import { getSearchWeight } from "../search-weights"; @@ -24,6 +24,12 @@ const { starlightRoute } = Astro.locals; const weightConfig = getSearchWeight(starlightRoute.id); const pagefindType = weightConfig?.metadata?.type; const pagefindWeight = weightConfig?.weight; +const markdownUrl = pathWithBase( + markdownPathForDocPath(starlightRoute.entry.id), +); +const agentSkillsGuideUrl = pathWithBase( + "/guides/ai-workbench/use-agent-skills/", +); // Build h1 attributes const h1Attrs: Record = { @@ -168,24 +174,700 @@ for (let i = 0; i < segments.length; i++) { )} -

- {starlightRoute.entry.data.title} -

+
+

+ {starlightRoute.entry.data.title} +

+ +
+ +