Skip to content

docs: serve llms.txt and a Markdown version of every page - #8246

Merged
Sepush merged 6 commits into
tusen-ai:docsfrom
Sepush:docs-llms
Oct 25, 2026
Merged

Sepush merged 6 commits into
tusen-ai:docsfrom
Sepush:docs-llms

Conversation

@Sepush

@Sepush Sepush commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Serves the docs to LLMs and agents (llms.txt), replacing #7502.

The docs are already Markdown: a component page is index.demo-entry.md plus its *.demo.vue files, and a docs page is index.md. So the LLM files are assembled straight from those sources by a build step. The site's own Markdown rendering is not touched.

What is served

Path Content
/llms.txt English index
/zh-CN/llms.txt Chinese index
/llms-full.txt, /zh-CN/llms-full.txt Every page in one file
/<lang>/<docs|components>/<page>.md One page, e.g. /en-US/components/button.md
  • Page Markdown: the page's Markdown, split with marked's lexer, with the demo block expanded into each demo's title, description and full source (debug demos left out, as on the site). Demos are read with @vue/compiler-sfc; the few site components written in the Markdown are parsed with Vue's template parser and become plain Markdown: <n-alert title> becomes a quote, <n-text code> a code span, linking elements become links, and any other tag keeps only its text. Relative links become absolute, pointing at the .md version of the page, so they still work inside llms.txt and llms-full.txt.
  • llms.txt: sections follow the site menu (Introduction, Getting Started, Common Components, Data Input Components, ...), and each link carries the page's first paragraph as its description. The changelog is under ## Optional, and left out of llms-full.txt.
  • One source of truth: the menu entries moved from demo/store/menu-options.js to a plain-data demo/store/menu-data.ts, which both the site menu and the build read. Each entry's Markdown source follows the existing file layout.
  • Dev and production: build/vite-plugin-llms.ts builds the files on request in the dev server and emits them as static files into site/ in the site build.
  • Where people find it: an "LLMs" page under Getting Started explains the files and how to hand them to an agent. The home page links to it under the main buttons, and so does the footer.
  • Encoding: naiveui.com serves static files without a charset, so the emitted files start with a UTF-8 byte order mark; without it a browser shows the Chinese as mojibake.
  • Copy button: a button next to "Edit on GitHub" in each page title opens a menu: copy the page as Markdown, copy the Markdown link, or view the Markdown.

Also fixes the language switch on the home page, broken since #8245: the home page is now the bare locale (/zh-CN), which the switch didn't match.

Compared with #7502

Tests

  • build/llms/tests: Markdown conversion, demo expansion, link resolution, descriptions, that every menu entry of both languages has a source, and the llms.txt structure.
  • Dev server: every path returns the right content type, and an unknown .md path falls through to the site.
  • Production build: the files are in site/.
  • Chromium: the copy menu copies the page and the link and opens the Markdown; the menu group counts are unchanged.

Assemble the LLM files from the docs' Markdown sources, without touching
how the site renders them:

- /llms.txt and /zh-CN/llms.txt: an index in site menu order, each link
  with the page's first paragraph
- /llms-full.txt and /zh-CN/llms-full.txt: every page in one file
- /<lang>/<docs|components>/<page>.md: one page, with every demo's title,
  description and source; site components become plain Markdown

Built on request by the dev server and emitted into site/ by the site
build. Each page title gets a menu to copy or view its Markdown.
@codecov-commenter

codecov-commenter commented Oct 25, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.56%. Comparing base (9422a5f) to head (8e39b84).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             docs    #8246      +/-   ##
==========================================
+ Coverage   63.53%   63.56%   +0.02%     
==========================================
  Files         878      878              
  Lines       27487    27487              
  Branches     8750     8524     -226     
==========================================
+ Hits        17465    17471       +6     
+ Misses       9809     9803       -6     
  Partials      213      213              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

naiveui.com serves static files without a charset, so a browser may
misread the Chinese. Start the emitted files with a byte order mark,
serve them with the charset in vite preview, and keep the English
llms.txt ASCII.
Since the theme left the path (tusen-ai#8245) the home page is the bare locale,
/zh-CN, which the switch didn't match.
- Split the page Markdown with marked's lexer instead of regexes
- Read demos with @vue/compiler-sfc, and parse embedded site components
  with Vue's template parser, one small function per tag
- Resolve links in one pass over the finished Markdown
- TypeScript only: menu-data.js becomes a typed menu-data.ts
- Split the work into site.ts, page-markdown.ts, template-to-markdown.ts
  and llms-txt.ts
@Sepush
Sepush merged commit 3940323 into tusen-ai:docs Oct 25, 2026
3 checks passed

This branch was previously deployed

1 inactive deployment
test — 8e39b84c Deployed Oct 25, 2026 by Sepush via test (24) #11272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants