Repository navigation
docs: serve llms.txt and a Markdown version of every page - #8246
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serves the docs to LLMs and agents (llms.txt), replacing #7502.
The docs are already Markdown: a component page is
index.demo-entry.mdplus its*.demo.vuefiles, and a docs page isindex.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
/llms.txt/zh-CN/llms.txt/llms-full.txt,/zh-CN/llms-full.txt/<lang>/<docs|components>/<page>.md/en-US/components/button.mdmarked's lexer, with thedemoblock 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.mdversion of the page, so they still work insidellms.txtandllms-full.txt.## Optional, and left out ofllms-full.txt.demo/store/menu-options.jsto a plain-datademo/store/menu-data.ts, which both the site menu and the build read. Each entry's Markdown source follows the existing file layout.build/vite-plugin-llms.tsbuilds the files on request in the dev server and emits them as static files intosite/in the site build.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
markedto unified).llms.txt.Tests
build/llms/tests: Markdown conversion, demo expansion, link resolution, descriptions, that every menu entry of both languages has a source, and thellms.txtstructure..mdpath falls through to the site.site/.