Skip to content

Feat/ai page access - #392

Open
TomShawn wants to merge 2 commits into
apache:mainfrom
TomShawn:feat/ai-page-access
Open

Feat/ai page access#392
TomShawn wants to merge 2 commits into
apache:mainfrom
TomShawn:feat/ai-page-access

Conversation

@TomShawn

@TomShawn TomShawn commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

closes: #ISSUE_Number


Change logs

Appending .md to any page URL now returns clean Markdown, and both readers and crawlers have a way to find it.

  1. Build-time Markdown export (src/plugins/markdown-export/) — every doc, blog post and Markdown page gets a plain-Markdown twin: /docs/introduction/cbdb-overview/docs/introduction/cbdb-overview.md. 1146 files, 8.6 MB. Nothing about the rendered site changes.
  2. A "Copy page" menu on every doc, PXF and blog page — copy the Markdown, view the source, or hand the page to Claude or ChatGPT as context.
  3. Discovery<link rel="alternate" type="text/markdown"> in each page's head, plus the .md URLs in sitemap.xml. Without this nothing can find the files: the menu is behind an open && guard, so its links never reach the server-rendered HTML.

Why

Readers increasingly paste a docs URL into an AI assistant, which today spends most of the context window on markup. Across the 503 released doc pages:

HTML Markdown
Total 38.4 MB 3.5 MB 9.1%
sql-stmts/create-table 435 KB 81 KB 18.6%
sql-stmts/close 79 KB 1.6 KB 2.0%

The 50× gap on short reference pages is typical — a 79 KB page carries 1.6 KB of content. The whole sql-stmts set is now 1.73 MB, small enough to hand over at once instead of being truncated.

The twins come from the Markdown source, not from scraping the rendered HTML, so tables, admonitions and code samples survive verbatim — including cases an HTML-to-Markdown converter mangles, like shell samples with export VAR=... or pg_filedump output containing literal <Header> markers.

Preview

image image

Cost

  • Build output +8.6 MB (the docs tree is already 141 MB). asf-site is content-addressed, so an unchanged .md produces no new object: roughly 1.2 MB in git once, then ~0.44 MB/year of churn.
  • sitemap.xml grows 1456 → 2086 entries. Every page appears twice, and ASF's static hosting gives us no way to send X-Robots-Tag: noindex on the Markdown half. Duplicate-content risk looks low (non-HTML text/* is generally not indexed) but is real — deleting the sitemap block in docusaurus.config.ts returns to HTML-only.
  • A sanitiser to keep current with: a new MDX component may need an entry in STRUCTURAL_TAGS / OPAQUE_TAGS. The plugin warns at build time when a component leaks into the output, deriving the list from each file's own imports so new components are covered automatically.

Deliberate omissions

  • docs/1.x skipped entirely — legacy, not worth the weight on every asf-site commit. Its HTML is untouched.
  • docs/next gets the menu but stays out of sitemap.xml — a contributor reading the dev docs should get the dev docs; a crawler should not answer user questions out of an unreleased version. 491 of its 516 pages are byte-identical to 2.x anyway.
  • No llms.txt — Ahrefs' server-log study of 137,000 domains found 97% of llms.txt files get zero requests, AI bots never probe for the path, and no major vendor has committed to reading it. sitemap.xml is the one discovery file crawlers demonstrably fetch.

Verification

1146 twins served as text/markdown; charset=utf-8, 0 failures, 0 residual component markup. sitemap.xml has 2086 entries, none pointing at a missing file and none from docs/next or docs/1.x. Menu and head link present on docs 2.x, docs/next, PXF, blog and Markdown pages; absent on docs/1.x, blog list pages and .tsx pages. Layout checked at 375–1920 px: the dropdown stays inside the viewport, and article and TOC widths are unchanged from main.

Contributor's checklist

Here are some reminders before you submit your pull request:

TomShawn and others added 2 commits August 5, 2026 13:55
Appending `.md` to any page URL now returns clean Markdown instead of an
82 KB HTML document. Measured over the 503 released doc pages, that is
38.4 MB of HTML against 3.5 MB of Markdown -- 9%, and closer to 2% on the
short reference pages, where a 79 KB page carries 1.6 KB of content. The
rest is navigation, scripts and styling that an LLM pays for and cannot
use.

The output comes from the Markdown source rather than from the rendered
HTML, so tables, admonitions and code samples survive verbatim. That
matters here: the docs contain shell samples with `export VAR=...`, Java
samples with `import java.sql.*;`, and pg_filedump output with literal
`<Header>` markers, all of which a line-oriented stripper corrupts. The
sanitiser tracks code fences and passes them through untouched, treating
only Docusaurus' `mdx-code-block` fences as transparent, since their
contents are evaluated rather than displayed.

A build-time self-check flags components that survive sanitising. It
derives the component list from each file's own imports, so a component
introduced later is audited without touching this plugin. Scanning for
bare capitalised tags instead is unusable -- the docs are full of
`<SEGID>`, `<PID>`, `<YYYYMMDD>` placeholders and Rust generics like
`<T>` that are prose, not JSX.

Two exclusion lists, both keyed by docs plugin id because version names
are only unique within an instance -- the unreleased version of every
instance is named `current`, so a flat list would take PXF down with
`docs/next`. `excludeVersions` skips a version outright (1.x, legacy);
`excludeFromSitemap` still exports and links the twin but keeps it out of
sitemap.xml, wired up in the next commit.

Nothing about the rendered site changes; this only adds files to the
build output.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The twins added in the previous commit had no entry point: nothing on the
site linked to a `.md` URL, and sitemap.xml listed only HTML. This adds
both, for the two audiences separately.

For readers, a "Copy page" menu on every doc, PXF and blog page: copy the
Markdown to the clipboard, open the plain-text source, or hand the page to
Claude or ChatGPT as context. The deep links use the canonical origin,
since a dev-server URL would be unreachable to a third party.

For crawlers, `<link rel="alternate" type="text/markdown">` in the head of
every page that has a twin, plus the `.md` URLs in sitemap.xml. The head
link is what makes discovery possible at all -- the menu is behind an
`open &&` guard, so its links never reach the server-rendered HTML.

`docs/next` gets the menu but stays out of sitemap.xml. A contributor
reading the dev docs should get the dev docs; a crawler should not be
answering user questions out of an unreleased version, and 491 of its 516
pages are byte-identical to 2.x anyway. Cost of listing the twins at all:
sitemap.xml grows from 1456 entries to 2086, and ASF's static hosting
gives us no way to send `X-Robots-Tag: noindex` on the Markdown half.
Deleting the `sitemap` block returns to HTML-only.

The sitemap reads the exported permalinks through a module-level set
rather than a file, because `postBuild` hooks run concurrently and would
race; `allContentLoaded` strictly precedes all of them.

Two layout notes: on narrow viewports the actions wrap onto their own line
instead of being pushed out of the viewport, and they stay flush right
once wrapped -- the dropdown is anchored to the trigger's right edge, so a
left-aligned trigger would send the panel off-screen. Blog pages align the
panel from the left instead, where the trigger sits.

Verified at 375/768/1280/1440/1728/1920 px: the panel stays inside the
viewport and the actions never overflow it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@TomShawn
TomShawn requested a review from tuhaihe August 5, 2026 06:12
@TomShawn TomShawn self-assigned this Aug 5, 2026
@TomShawn TomShawn added documentation Improvements or additions to documentation enhancement New feature or request javascript Pull requests that update javascript code labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant