Repository navigation
fix(llms): keep component rewrites on fumadocs-core 16.19 and later - #20
Conversation
Fumadocs 16.17 writes the Markdown copy from a page's source, so the stringify and extensions options are gone. A remark plugin now edits the source for each rewrite, code block header and table. Floors move to 16.19.7 for core and ui, which pins core exactly; ui 16.19.7 renamed three label keys.
aicayzer
left a comment
There was a problem hiding this comment.
Review: ready to merge
Summary. The kit writes the Markdown copy by editing the page's source through a remark plugin, which fumadocs-core 16.19 and later builds the copy from, and a real-site build now matches the copy made on 16.15.15; safe to merge, with the setup change below released together with the sites that adopt it.
First draft: 3/5. Unit and preset tests passed, but a build of docs.marfa.so against the packed kit showed three blocking faults, all fixed in b2d3142: <include> left as a raw tag, text garbled at wrong offsets on pages with includes, and tab= fences losing their label while leaking tab and tab-group.
Checked.
- Done: the old
llmsOptionson 16.15.15 and the newllmsCopyon 16.19.8 compared through the realapplyMdxPreseton 14 pages, then on the docs site's wholellms-full.txt. After normalising list markers and blank lines, the only differences are 12 type-list rows that no longer leak raw<Icon>markup (correct under the site'sIconrewrite) and whitespace in empty table cells. No<include,tab=ortab-grouptext remains, and heading anchors match. - Every path: includes (relative,
cwd, inside a component, the same file twice, a tab inside an include) andtab=blocks run through the installedfumadocs-mdxremarkInclude, the preset, the kit plugin andremarkLLMs; 8 of these fail on the previous head. - True: the peer floors are the first releases that work:
fumadocs-core16.19.0 for themarkdownnamespace,fumadocs-ui16.19.7 for the renamed label keys (one floor for both, as ui pins core), andfumadocs-mdx15.4.7, the first that records an included file's source withembedSource. The full suite passes at the floor and on the newest releases. - Stale instructions: the README states the new setup (
llms.optionsandllms.plugin), the floors and why, and hownpmandtab=blocks are copied.
Found.
- Raw
<include>and garbled text on pages with includes. fumadocs-mdx before 15.4.7 does not record where included text came from. Fixed in b2d3142 by raising the peer floor; tests run the realremarkInclude.Done tab=fences lost their label and leaked attributes. Fixed in b2d3142: the label goes on the first positioned node inside the tab, and the fence dropstabandtab-group.Done- Plugin-added nodes in table cells were dropped. A cell holding an unpositioned node is now written from its children. Fixed in b2d3142.
Every path - A callout opening with a fenced block glued the fence to the title line (also on main). Fixed in b6674d5.
Every path - A comment named Fumadocs 16.15. Reworded in b6674d5.
Stale instructions npmandpackage-installblocks keep the authored fence instead of one fence per package manager, becauseremarkNpmpins the authored block as the source. Accepted and documented in the README; no information is lost.Done
For an issue.
- Breaking change for both sites.
llmsOptionsis gone. The next docs-kit release needs a version bump, and each site must addllms.pluginand move tofumadocs-core/fumadocs-ui16.19.7+ andfumadocs-mdx15.4.7+ when it adopts that release. A site that omits the plugin builds without error but copies components as written.
Reviewed by withmarfa-reviewer on claude-sonnet-5-5, with a real-site check by the session. This review may contain mistakes.
Summary
Markdown copies and
llms-full.txtlose every component rewrite and code block header onfumadocs-core16.17.0 and later, without a build error. Fumadocs now writes the copy from a page's own source, soLLMsOptionsno longer acceptsstringifyorextensionsand silently ignores them. This change writes the same copy through the API that replaced them, moves the development dependencies to the newest 16.x and 15.x, and narrows the peer ranges to the releases docs-kit is tested against. Closes #19Changes
llmsOptions()is replaced byllmsCopy(), which returns{ options, plugin }.optionsis{ output: 'string' }.pluginis a remark plugin that callsreplaceSource(file, node, text, 'markdown')fromfumadocs-core/mdx-plugins/stringifierfor each rewrite, wrapper,Figure:line, dropped component, code block with a note or status, code block with notation comments, and table. Themarkdownnamespace keeps the edits out of search records.attribute,inner,flow,node), now read from the page source instead of mdast stringification. Tables are written from their cells, so they stay unpadded whatever the source looks like, and a rewrite inside a cell still applies.llms.plugintoremarkPluginsand passesllms.optionstoincludeProcessedMarkdown. The README shows both.tab="..."is written as its label in bold, then the fence withouttabandtab-group. Fumadocs'sremarkCodeTabreads those attributes into a tab element that has no position in the source, so a rewrite of that element can never apply. The plugin now writes what the element's rewrite puts around its content (the**label**) as an edit to the first node inside it that has a position, and rewrites the fence itself without the attributes.fumadocs-mdx15.4.7 or later. Thefumadocs-mdxpeer moves from^15.4.5to^15.4.7. Through 15.4.6,fumadocs-mdx's ownremarkIncludeputs the included file's nodes into the page tree without recording that their positions belong to another file, so every edit lands at the wrong offset of the page's source. 15.4.7 adds theembedSourcecall that fixes this. Nothing in the kit can repair it from outside: the copy is made from the source and the wrong offsets are already in the tree.fumadocs-coreandfumadocs-uipeers move from^16.15.15to^16.19.7; dev dependencies move from 16.15.15 to 16.19.8, andfumadocs-mdxfrom 15.4.5 to 15.6.4.mdast-util-gfm-tableis no longer used and is removed.fumadocs-uimoves with core because each ui release pinsfumadocs-coreto its own version in its peer range, so 16.15.15 cannot sit beside core 16.19.8. The move needed three follow-ups:translations.tsrenames three label keys (404 pagebecame404 not found page,mobile menubecamehome layout header) and adds the four new title-case labels (Skip to Content,Image Viewer,Next Image,Previous Image);translations.test.tsreads the renamedkeys.json.js; the page actions test'sfetchstub now returnsok: true, which ui 16.19 checks.llms.test.tsruns the plugin andremarkLLMsas separate steps, adds cases for nesting in lists and quotes, longer fences, padded and aligned tables and components in cells, and a block that runs the installedfumadocs-mdx's ownremarkInclude, the real Fumadocs preset (applyMdxPreset), the kit's plugin andremarkLLMsin the order of its loader. That block covers a page holding every rewrite, includes (relative andcwd, with a heading, a table and a code block inside; inside a component; a non-Markdown file; the same file twice; a tab inside an included file) andtab=blocks (labels,tab-group, title and note, several blocks in one tab, a tab in a list item), plus the install-tab case below and a plugin-added icon in a cell.Testing
Run in the worktree through
heavy-run, onfumadocs-coreandfumadocs-ui16.19.8 withfumadocs-mdx15.6.4:pnpm types:check: clean.pnpm test: 34 files, 382 tests passed.pnpm build: succeeded.pnpm pack:check: "The package holds what it should and imports only what it declares."types:checkalso pass on the declared floor: core and ui 16.19.7 withfumadocs-mdx15.4.7.Seen failing first: the previous
llms.test.ts, run against 16.19.8, failed 16 of its tests. The include and tab tests added here fail on the previous head (b6674d5, withfumadocs-mdx15.4.5): 8 tests, with the garbled output (## Fie [#identity]ld| every | m has | ...), the raw<include>tag and thetab="..."attributes in the copy. On the new code the five include tests still fail onfumadocs-mdx15.4.5 and 15.4.6, and all pass on 15.4.7, 15.4.8, 15.4.9, 15.4.10, 15.5.0, 15.5.3, 15.6.0 and 15.6.4, each on core 16.19.7 and 16.19.8.Against a real site: the kit was packed and installed in a scratch checkout of withmarfa/docs at
main(not committed), withsource.config.tschanged tollmsCopyandllms.plugin, andllms-full.txtfrompnpm buildwas compared with the one from the kit atmainonfumadocs-core16.15.15. The new file is identical onfumadocs-mdx15.4.7 and 15.6.4. After ignoring list markers (*and-), blank lines and trailing whitespace, 12,521 old lines and the new file differ only as listed under Output differences. No<includetag and notab=ortab-grouptext remains, all 757 heading anchors match, and the scratch checkout was restored tomain.Not tested: a build of either consuming site as committed (withmarfa/docs is out of scope here, and neither site is updated);
fumadocs-mdx's own loader as a whole, whose postprocess step callsremarkLLMs, so the test runs the preset andremarkLLMsitself in that order; a<show>branch oroutput: 'function'content source, which the kit does not support.Notes for reviewers
llmsOptionsis gone, a site must addllms.plugin, and a site onfumadocs-mdxolder than 15.4.7 must update it, or its copies of pages with<include>are garbled. PerAGENTS.mdthis needs a version bump and both consuming sites updated; no version is bumped here.markdownnamespace from 16.19.0. The ui floor is 16.19.7 because the label keys infumadocs-uichanged between 16.19.5 and 16.19.7, so on an earlier ui the translations would silently stop applying. Because ui pins core exactly, a site on ui 16.19.7 or later is on core 16.19.7 or later, so both peers use that floor. The code itself works from core 16.19.0.filterElementreceives a node and no file.~/Library/...), where the old copy escaped it (\~/Library/...).<Icon body="<path ...>" />markup that the old copy leaked into the first cell of each row. The site'sIconrewrite says an icon is not text, and the cell now applies it. The Mark column of the connector index still writes the mark's ID, as before.| |where the old copy wrote| |(whitespace only).npmorpackage-installblock keeps the fence as authored (```npm). The old copy read the generated install tabs from the tree and wrote them (inferred from the old code, not run). Fumadocs's ownremarkNpmreplaces the block with tabs that have no position and pins the authored block as the page's source, and the original node is no longer in the tree for the kit to rewrite. The docs site has no such block.Checklist