diff --git a/README.md b/README.md index 236cca2..a814090 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ docs-kit builds on a stack that your site already uses: * Node 22 or later. * A TanStack Start site on Cloudflare Workers, built with Vite and Tailwind CSS 4. -* Fumadocs: `fumadocs-core` and `fumadocs-ui` 16.15.15 or later in version 16, and `fumadocs-mdx` 15.4.5 or later in version 15. +* Fumadocs: `fumadocs-core` and `fumadocs-ui` 16.19.7 or later in version 16, and `fumadocs-mdx` 15.4.7 or later in version 15. Earlier `fumadocs-mdx` releases include a file without recording where its text came from, so the Markdown copy of a page with `` is garbled. The peer dependencies are `react`, `react-dom`, `fumadocs-core`, `fumadocs-ui`, `fumadocs-mdx`, `@tanstack/react-router` and `lucide-react`. `posthog-js` is an @@ -80,17 +80,21 @@ draws as plain monospace text with no chip. ### Configure the MDX source In `source.config.ts`, import from `@withmarfa/docs-kit/config`, not from `/mdx`: the config entry reaches Fumadocs's Node-only plugins, and `/mdx` stays free of them so a page can load it in the browser. Use `codeOptions` for code highlighting and -`llmsOptions` to write the Markdown copy of each page. `llmsOptions` already +`llmsCopy` to write the Markdown copy of each page. `llmsCopy` already writes the kit's own components (`Callout`, `Cards`, `Steps`, `Terminal` and the -others); give it a rewrite for each component that your site adds: +others); give it a rewrite for each component that your site adds. It returns +two parts that work together: the `options` that ask Fumadocs for the copy as +text, and the `plugin` that writes each component, fenced block and table of +the copy. Fumadocs writes the copy from a page's own source, after the remark +plugins have run, so the plugin goes in `remarkPlugins`: ```ts // source.config.ts import { defineConfig, defineDocs } from 'fumadocs-mdx/config'; import { pageSchema } from 'fumadocs-core/source/schema'; -import { codeOptions, llmsOptions, rehypeTableLabels } from '@withmarfa/docs-kit/config'; +import { codeOptions, llmsCopy, rehypeTableLabels } from '@withmarfa/docs-kit/config'; -const llms = llmsOptions({ +const llms = llmsCopy({ // Components whose children are the content: the copy keeps the children. wrappers: ['ReferenceList'], // Components that need their own text. Each rewrite returns Markdown. @@ -103,18 +107,29 @@ export const docs = defineDocs({ dir: 'content/docs', docs: { schema: pageSchema, - postprocess: { includeProcessedMarkdown: llms }, + postprocess: { includeProcessedMarkdown: llms.options }, }, }); export default defineConfig({ mdxOptions: { + remarkPlugins: (plugins) => [...plugins, llms.plugin], rehypePlugins: (plugins) => [...plugins, rehypeTableLabels], rehypeCodeOptions: codeOptions(), }, }); ``` +A rewrite is given the element's `attribute(name)`, its content as Markdown with +`inner()`, and `flow(children)` for nodes you pick from `node.children`. Without +`llms.plugin` in `remarkPlugins`, the copy still builds but keeps every +component as written, so a page's Markdown holds JSX. + +The copy writes a fenced block with `tab="..."` as the tab's label in bold, then +the block without its `tab` and `tab-group` attributes. An `npm` or +`package-install` block keeps the fence as written: Fumadocs's own `remarkNpm` +pins the authored block as the page's source, and the copy follows it. + `codeOptions` takes the same options as Fumadocs's `rehypeCodeOptions`, such as `langs` for a custom grammar. It keeps Fumadocs's notation comments, which `styles.css` draws: end a line with `// [!code highlight]` for a quiet tint diff --git a/package.json b/package.json index a898b85..5ee6e73 100644 --- a/package.json +++ b/package.json @@ -63,15 +63,14 @@ }, "dependencies": { "@types/mdx": "^2.0.14", - "mdast-util-gfm-table": "^2.0.0", "tailwind-merge": "^3.7.0", "yaml": "2.9.1" }, "peerDependencies": { "@tanstack/react-router": ">=1.170.0", - "fumadocs-core": "^16.15.15", - "fumadocs-mdx": "^15.4.5", - "fumadocs-ui": "^16.15.15", + "fumadocs-core": "^16.19.7", + "fumadocs-mdx": "^15.4.7", + "fumadocs-ui": "^16.19.7", "lucide-react": ">=1.48.0", "posthog-js": ">=1.434.0", "react": "^19.3.0", @@ -88,9 +87,9 @@ "@types/node": "^26.6.3", "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", - "fumadocs-core": "16.15.15", - "fumadocs-mdx": "15.4.5", - "fumadocs-ui": "16.15.15", + "fumadocs-core": "16.19.8", + "fumadocs-mdx": "15.6.4", + "fumadocs-ui": "16.19.8", "jsdom": "^31.0.1", "lucide-react": "^1.48.0", "posthog-js": "^1.434.16", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c7d09d..a64012f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ importers: '@types/mdx': specifier: ^2.0.14 version: 2.0.14 - mdast-util-gfm-table: - specifier: ^2.0.0 - version: 2.0.1 tailwind-merge: specifier: ^3.7.0 version: 3.7.1 @@ -37,14 +34,14 @@ importers: specifier: ^19.3.0 version: 19.3.0(@types/react@19.3.3) fumadocs-core: - specifier: 16.15.15 - version: 16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7) + specifier: 16.19.8 + version: 16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7) fumadocs-mdx: - specifier: 15.4.5 - version: 15.4.5(@types/mdast@4.0.4)(@types/mdx@2.0.14)(@types/react@19.3.3)(fumadocs-core@16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react@19.3.1)(rolldown@1.3.4)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 15.6.4 + version: 15.6.4(@types/mdast@4.0.4)(@types/mdx@2.0.14)(@types/react@19.3.3)(fumadocs-core@16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react@19.3.1)(rolldown@1.3.4)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(yaml@2.9.1)) fumadocs-ui: - specifier: 16.15.15 - version: 16.15.15(@types/mdx@2.0.14)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(fumadocs-core@16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(tailwindcss@4.3.5) + specifier: 16.19.8 + version: 16.19.8(@types/mdx@2.0.14)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(fumadocs-core@16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(tailwindcss@4.3.5) jsdom: specifier: ^31.0.1 version: 31.0.1 @@ -280,8 +277,8 @@ packages: '@types/react': optional: true - '@fumadocs/tailwind@0.1.2': - resolution: {integrity: sha512-VppeXgIRXjZMgpf2qijj1hcfxyeYl1s0ok8k6N3jyjiX64M7sDwnt2zGPd6dbfDybgbBvDw6C6J1e42gB5NzsA==} + '@fumadocs/tailwind@0.1.5': + resolution: {integrity: sha512-ohzmuLTfNNRvP6B/Xx31lWJ58xu40NcmI+6mc/jivYeOoofnmdxBKu5gCErTgOE/mUqyVv4GvYeqd9FhoLHphg==} peerDependencies: tailwindcss: ^4.0.0 peerDependenciesMeta: @@ -1124,83 +1121,71 @@ packages: '@vitest/spy@5.1.2': resolution: {integrity: sha512-PQl0/3+p9GaY71+MHywN6oyHfLhVDD5kcbm7oNRldA2F0ExMU3S8RQdnpteJ9gFAdK5P6KCgE6LqCpUgy57KzA==} - '@yuku-analyzer/binding-android-arm64@0.10.2': - resolution: {integrity: sha512-xt4Vy3RTBw1NfszBlf4A0Rr6ZjA/th2Pj9XlWFLQHW9A1qOCtxNCoIWSzn/INtnZLMB4jO2gWdEtSaHUtK73wA==} + '@yuku-core/binding-android-arm64@0.19.0': + resolution: {integrity: sha512-wdL2XmTiZixAOaHk9Z0JJZ8u9Qm8d333Zjpc6gaxXFX+UR5BlsfxZ7a2+2Rm71pamppsPYGUGFq2oVLbh6DISw==} cpu: [arm64] os: [android] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-darwin-arm64@0.10.2': - resolution: {integrity: sha512-ftokSqvYXZxfmA/bfIbp8c1BJ8QxNax371kUOQNFyvR5hmtKqQyTqSKtMk+WaixHM3w4tKj/JdyY+ud1bGamXA==} + '@yuku-core/binding-darwin-arm64@0.19.0': + resolution: {integrity: sha512-7sNJa6XJhyetnTy64jw3NEi4YgUcezHk1G5GH9FSvXAuC8wIlbaOwT9lgq5qo5sspjrZJQlBR1TWflP49uRpMw==} cpu: [arm64] os: [darwin] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-darwin-x64@0.10.2': - resolution: {integrity: sha512-yUrmmhmF5R4Xmbfo8gUxJKr3YbvbLcE2JvLhDLzFJkMN29/fGm6K3dZX6YpNecfgBDnQ+VywGp8K9xjRaBFZ3Q==} + '@yuku-core/binding-darwin-x64@0.19.0': + resolution: {integrity: sha512-pTC7dYEc59isdyizc3nsuyFNBu2LU5wMYZ1be6UMr59PY/AJNtO1aBLWV0MgL/z7C1nv/2sX4TNjGgKLoeevJw==} cpu: [x64] os: [darwin] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-freebsd-x64@0.10.2': - resolution: {integrity: sha512-cy9+KvVoK5Xad3Vs5pLwAeZf3JC/1y0XJElgv1q6g7W7g/n52FRjedpYmQiJeMZdnhJiAshq7Vz/Xj3jC5Ns2Q==} + '@yuku-core/binding-freebsd-x64@0.19.0': + resolution: {integrity: sha512-xrZjF6XOEwyLOiDIfrwDdRCS6ghxcJeirNC1KivQhVcUwlRonaU79S3/Uiyx3lBylPnT8qKJ3/aMT+H52nGTJQ==} cpu: [x64] os: [freebsd] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-linux-arm-gnu@0.10.2': - resolution: {integrity: sha512-AgVZ6VCV2XP4yHCwyv78KLV76gcu2neiEF2+RBTPQN7sqYY+bLvMxphGPmfG+9qk5Uf1PJAhZYIUnMGVbbRCZw==} + '@yuku-core/binding-linux-arm-gnu@0.19.0': + resolution: {integrity: sha512-0OyIH53C0I1CbADHn9FSdCfX5qbpeLwJhmOVhonFJNYheybOnkSJ50qGMfTJIb8y5zrwqvLs7FVBvz6Fk8maZg==} cpu: [arm] os: [linux] libc: [glibc] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-linux-arm-musl@0.10.2': - resolution: {integrity: sha512-5qAj2GjoSN6+HuH75+g5r40CFhWmMvH0K8VKWmPfQyOgA/LonoDMr5H5O5feJwzdnfdCytPDAh1RAf7/SSg7dg==} + '@yuku-core/binding-linux-arm-musl@0.19.0': + resolution: {integrity: sha512-z/iPfkCOCSXE34VXNt0uP1ORSW+4mEa9b5CiJcWZeqZH08g49bFU/jRM2T04f+Wpw5mJ6HIzNBiojxeAbrHjeg==} cpu: [arm] os: [linux] libc: [musl] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-linux-arm64-gnu@0.10.2': - resolution: {integrity: sha512-eJvQ4Ja5oPf/HOjmBkCLYyhOHUkL7U+iMAN8sX44x8exBBpPRyqnhEgTsuU73HzxPLrGPdRhybFnAE63Omib/Q==} + '@yuku-core/binding-linux-arm64-gnu@0.19.0': + resolution: {integrity: sha512-jLNTi+gzaRwBJ+gwhCJ+rDb5dmx/8hEBx93UWd7hjMSqPTL1D1wvVSvXVAldV5kALvju7b0/m51EHEhs4+I1fA==} cpu: [arm64] os: [linux] libc: [glibc] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-linux-arm64-musl@0.10.2': - resolution: {integrity: sha512-TppF2j194mOQ/kBXvNr9u5TYO+eR9r8ieg4lTIEyJIVYHAR9GWeB0oFHLcJiLXVa3qUJGzE4bmzSntCW5ylA7A==} + '@yuku-core/binding-linux-arm64-musl@0.19.0': + resolution: {integrity: sha512-YwyPIdW/rN2Fmv0MTFWi47FaB3F9g+2b+sJISyAw83Yd60RWH4T3Nx6XkAHHVN+uKJNBAd6So7/BVihSiFYvuQ==} cpu: [arm64] os: [linux] libc: [musl] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-linux-x64-gnu@0.10.2': - resolution: {integrity: sha512-03xu6ocJuwhm1a/JKmrHiaJUO1Oj86rABsm4FAl8AvfewfW/9idIUmPiFxZfb6RfiIONegebsTGJhFx0NbBNpA==} + '@yuku-core/binding-linux-x64-gnu@0.19.0': + resolution: {integrity: sha512-/vskaAXVX3ESR43FiTdfiYS7z1b9uoQJwVQ/0RgUHgN2sWoAyCZs+aX4CgU7eKGIHTVfp9VFwv+c+2XchYiEtQ==} cpu: [x64] os: [linux] libc: [glibc] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-linux-x64-musl@0.10.2': - resolution: {integrity: sha512-f7W2sAWWQN8x8YB0RRxIche7mLImH7lDgzUy9+B69cM2I6VFJ4a5+0pgAuMLROPOqimaxFPdXqLdDE/vpgGltg==} + '@yuku-core/binding-linux-x64-musl@0.19.0': + resolution: {integrity: sha512-FuXL5igeSKib9Rye02TdH+D6SQezTyGxIATMu1Qsn/QywrzwpGl35OLpS2C1x5vpGLeVE2XgiLd5mVPFHmIglQ==} cpu: [x64] os: [linux] libc: [musl] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-win32-arm64@0.10.2': - resolution: {integrity: sha512-f534qNc5YaJI29e1oryxEnxPkp7WCYJ1j7ChSec8pQNlYqTm8Tao7hij7NxRF+9BuxzeZCZ+WsbaAfLlklR0Eg==} + '@yuku-core/binding-win32-arm64@0.19.0': + resolution: {integrity: sha512-YuJAe7zEKT1Xa7LuHlhGJpPnYQeVtvo0rZvNjJRqkH0hQGOw4C8QeP30Tg5VKGzZfo2x8CjhjEhKt4TmLwfmdg==} cpu: [arm64] os: [win32] - deprecated: yuku-analyzer runs on yuku-core since 0.14 - '@yuku-analyzer/binding-win32-x64@0.10.2': - resolution: {integrity: sha512-sKHkmLK8BsindMfyIThoN0bWC5uqSJEVNaLRD/ifA99mtb0UDin1ZCg4WYSVQAmM4k2iOTl4UZx/p3zcBiBgYw==} + '@yuku-core/binding-win32-x64@0.19.0': + resolution: {integrity: sha512-o8iY/mXwlRkedp0LNTr4+TEfXTPQwoNZmv6k+1WIAd1ZXEn8xJJTBCtB0osaVvdZo/x/cNmV16UrWrrGpM5Mvw==} cpu: [x64] os: [win32] - deprecated: yuku-analyzer runs on yuku-core since 0.14 '@yuku-toolchain/darwin-arm64@0.28.1': resolution: {integrity: sha512-xMtZUwiGvJH90ogLjRrnG5+YEhinKti8qMPF18bd5z0ahSoaHWyBoe16evT7cSUxid0JEaZvh6H3daDPwDw4+g==} @@ -1222,8 +1207,8 @@ packages: cpu: [x64] os: [linux] - '@yuku-toolchain/types@0.10.2': - resolution: {integrity: sha512-sSeo4SSSToiS+sSD+bwn/s94EEcaLJ7tG5LCp8gFYC1G5VzxzX7fqB6m9RU1yMD8KTpu6zdU/I1NlQf8hVBJ9Q==} + '@yuku-toolchain/types@0.19.0': + resolution: {integrity: sha512-tFkNbsP4WXX9UMUC5syJGdK9dPMLK0PPaIuXCcCYH75sZ8MrebfBZ2XvCILRTw8AgLivSSCfDa4R67iYBDa4Kg==} '@yuku-toolchain/win32-arm64@0.28.1': resolution: {integrity: sha512-CUiumoJIwNiH9Utm5SbG5GaEaJRUatEXgG5HcPj2yEWh4kxTmEbigB346C3HEmtc+zbRLY0T0XsFO5RGSZaj2A==} @@ -1289,9 +1274,9 @@ packages: character-reference-invalid@2.0.1: resolution: {integrity: sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==} - chokidar@5.0.0: - resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} - engines: {node: '>= 20.19.0'} + chokidar@6.0.0: + resolution: {integrity: sha512-Ec2Z7wpcKBiMpR7DxteoqS/sq5G5d2A4fpxzPv6+fD7xNNdrTghn7L11YwV5EN1B3i72Erc3XVT5FkWIDx90+A==} + engines: {node: '>= 22.22'} class-variance-authority@0.7.1: resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==} @@ -1300,9 +1285,9 @@ packages: resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} engines: {node: '>=6'} - cn@0.3.3: - resolution: {integrity: sha512-OEiyJkSpYm2kOuNOKQ+c2wmzZRG8orrb9fnObtHTbCGNx/E9KLnGcmcocItOzREKk5KzQN5I2e3BUCj563KEpw==} - engines: {node: '>=20'} + cn@0.5.2: + resolution: {integrity: sha512-wm10E6iuJ37rALOw3D+3cfaXXZSLNMh2uxpQn3dNICqfJM59yXqgbA9/9Iiz155j5kYNLdK6WreNdW3NQtx3OQ==} + engines: {node: '>=22'} hasBin: true collapse-white-space@2.1.0: @@ -1444,30 +1429,34 @@ packages: fflate@0.4.9: resolution: {integrity: sha512-zdxgIEddhfsyCaWpJ2SdXEP8ZMrKJ6+5jl4OupODcywU0IhRk6gdXuVGcPICyfx2H97hVK7xmJtRLPjkxAX8Vw==} - framer-motion@13.5.1: - resolution: {integrity: sha512-HeWOaeHD3kyTSIEMT6+nw7fBn4saIfxxabZyAITbycAl4xr1kzGJKIvGt/OWghSlvIA9qTnZ1zTGelHAe6S8DA==} + framer-motion@14.14.0: + resolution: {integrity: sha512-fidRX0VzkZdA9OovFiBSzJtt9/jLcJpna78Z+KCqQQZIWoIpN3tOhEXAhhAw/FObUUh+o3Y18yx1F4BP0mVJ8Q==} peerDependencies: react: ^18.0.0 || ^19.0.0 react-dom: ^18.0.0 || ^19.0.0 + remix: ^3.1.0 peerDependenciesMeta: react: optional: true react-dom: optional: true + remix: + optional: true fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] - fumadocs-core@16.15.15: - resolution: {integrity: sha512-kEQLKRlpRl16MfMrlAYiEpk3FPadn4725R3QHYVnF3tJhflRXvznWaJ5pP33F09d6qnOss5onEIgMpAO6rOrpA==} + fumadocs-core@16.19.8: + resolution: {integrity: sha512-kKWLk5GWvxwvdjbnJnhhYapK701C/uzJOrhqXsp+i5tSuPxEo6NSf/aTfZ/YMjkuXbB5z3isH7bcKbEe3EoauA==} peerDependencies: '@mdx-js/mdx': '*' '@mixedbread/sdk': 0.x.x '@modelcontextprotocol/server': 2.x.x '@orama/core': 1.x.x '@oramacloud/client': 2.x.x + '@pierre/highlights': 0.x.x '@tanstack/react-router': 1.x.x '@types/estree-jsx': '*' '@types/hast': '*' @@ -1476,6 +1465,7 @@ packages: algoliasearch: 5.x.x flexsearch: '*' lucide-react: '*' + meilisearch: '>=0.50.0 <1.0.0' next: 16.x.x react: ^19.2.0 react-dom: ^19.2.0 @@ -1493,6 +1483,8 @@ packages: optional: true '@oramacloud/client': optional: true + '@pierre/highlights': + optional: true '@tanstack/react-router': optional: true '@types/estree-jsx': @@ -1509,6 +1501,8 @@ packages: optional: true lucide-react: optional: true + meilisearch: + optional: true next: optional: true react: @@ -1522,20 +1516,21 @@ packages: zod: optional: true - fumadocs-mdx@15.4.5: - resolution: {integrity: sha512-r8gzaqleN+YXgPIbkYSZ05zr89dsr67/64Ar/00Uu7dRWTIHzbgmN1nC0lB8RFNeWnrL41bOTJilhLM4PAsrbw==} + fumadocs-mdx@15.6.4: + resolution: {integrity: sha512-b5z5GjDxDzdc9K1/HwAL6X77xj0ddinJ5FJFXeIxYCRRQq2rqSFNTNAd2fo2UmQnr87jkuE25+o5iAV0mg48lw==} hasBin: true peerDependencies: '@fumadocs/satteri': 0.x.x '@types/mdast': '*' '@types/mdx': '*' '@types/react': '*' - fumadocs-core: ^16.15.3 + '@vitejs/plugin-rsc': ^0.5.34 + fumadocs-core: ^16.18.3 mdast-util-directive: '*' next: ^15.3.0 || ^16.0.0 react: ^19.2.0 rolldown: '*' - satteri: ^0.10.5 + satteri: ^0.11.7 vite: 7.x.x || 8.x.x peerDependenciesMeta: '@fumadocs/satteri': @@ -1546,6 +1541,8 @@ packages: optional: true '@types/react': optional: true + '@vitejs/plugin-rsc': + optional: true mdast-util-directive: optional: true next: @@ -1559,12 +1556,12 @@ packages: vite: optional: true - fumadocs-ui@16.15.15: - resolution: {integrity: sha512-wE9gTz+JYoz9wwxaNCfj7jqN7c7oAY7lCyuFootpY8jmGiyZHfy6db2cxlRwjm+qEaLdsV/KOsAjbuuT/n8elg==} + fumadocs-ui@16.19.8: + resolution: {integrity: sha512-rVwME6IBCwwgDu3sADmnAYctvedWPZxDGylLIilMVSAPPIUsvnIFnP6KB3/iynRuIuqnIpdmdtscXhY6Gnzpvg==} peerDependencies: '@types/mdx': '*' '@types/react': '*' - fumadocs-core: 16.15.15 + fumadocs-core: 16.19.8 next: 16.x.x react: ^19.2.0 react-dom: ^19.2.0 @@ -1593,15 +1590,12 @@ packages: graceful-fs@4.2.12: resolution: {integrity: sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw==} - hast-util-from-parse5@8.0.4: - resolution: {integrity: sha512-Yq7XlXor0Cpb71sI2E0zpv8QxQ5a6rfhDEETk4bcgrFX2SvJAY2PHocWwFtL6U9qyfiyByW3wZ6sZEfP2kW81g==} + hast-util-from-dom@5.0.1: + resolution: {integrity: sha512-N+LqofjR2zuzTjCPzyDUdSshy4Ma6li7p/c3pA78uTwzFgENbgbUrm2ugwsOdcjI1muO+o6Dgzp9p8WHtn/39Q==} hast-util-parse-selector@4.0.0: resolution: {integrity: sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==} - hast-util-raw@9.2.1: - resolution: {integrity: sha512-8P0PLAr5C7xCRb+tkhUTV4v6OSNcnccKwjBkH/r19R5CkVCgTWlv4vmTkxFH1CVCA2UJOvOPQdBBMC3c6qnuOg==} - hast-util-to-estree@3.1.3: resolution: {integrity: sha512-48+B/rJWAp0jamNbAAf9M7Uf//UVqAoMmgXhBdxTDJLGKY+LRnZ99qcG+Qjl5HfMpYNzS5v4EAwVEF34LeAj7w==} @@ -1611,9 +1605,6 @@ packages: hast-util-to-jsx-runtime@2.3.7: resolution: {integrity: sha512-F7DNV2NMcTxA4GqPVHnXzX+mpoPHAIY9rJAVH3CZ1FdBZOcBUEjUuvMkMpHVs/sicEtznh9tMGj5WUR9S4E2rg==} - hast-util-to-parse5@8.0.1: - resolution: {integrity: sha512-MlWT6Pjt4CG9lFCjiz4BH7l9wmrMkfkJYCxFwKQic8+RTZgWPuWxwAfjJElsXkex7DJjfSJsQIt931ilUgmwdA==} - hast-util-whitespace@3.0.0: resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==} @@ -1932,22 +1923,25 @@ packages: micromark@4.0.3: resolution: {integrity: sha512-oGYfQzHSG5dOMovQcJ3fyTmZlWAWpi0XA0sJwJs+i6OT88o1+Jtw/8z0CmdowSLxGhhFK89rQ/oXph/wN02PNw==} - motion-dom@13.5.1: - resolution: {integrity: sha512-/7CVCD20Mz1KobktorpdgvowV0V41J7UxqE+qWS3GkSJqrRr5ft+2RloOYtEKv+wvBp3JaSFBclhxt4ja8ovHg==} + motion-dom@14.14.0: + resolution: {integrity: sha512-IAxcKhYkuQA2W0Tlx1AvVgImfqEoF3/t3IovbPQJlYkefmGsmrXjn967lMII5VmFmLpQEab4+ZkHo/ijJ4Esig==} - motion-utils@13.5.0: - resolution: {integrity: sha512-Hqe/sqjIKliPZg8sVjWAkdySDPJNIeKH+euVkDOG8ri3DUUU7ZjndmHsGqEPz2iHpiyVaV5I22iguCMHU2he+Q==} + motion-utils@14.7.0: + resolution: {integrity: sha512-woO0/Nb7ys75f94fjvQi/6leiHGvZUYkeHUPEZ3vxsV+9OpEVhkxp01x8MlRwX0zt31EqgXsKDAoBoJLC148Tw==} - motion@13.5.1: - resolution: {integrity: sha512-eV9SUem6KnzEa9+eT+dVBeDlhy5TTdn09YWR1WhUsKoZCJPw/n4TcYhjbxq2Gy5PTwDr//4H3r5vxkcZnNnO1w==} + motion@14.14.0: + resolution: {integrity: sha512-a306U6sV5VKq1abtzKiinB+UQjiY88jrsvQzWORP3WPv/DFANyoYVlPbdnmJPMEbusyPXB4GyQJVANaq/pSIYQ==} peerDependencies: react: ^18.0.0 || ^19.0.0 react-dom: ^18.0.0 || ^19.0.0 + remix: ^3.1.0 peerDependenciesMeta: react: optional: true react-dom: optional: true + remix: + optional: true ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -2101,9 +2095,6 @@ packages: regex@6.1.0: resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==} - rehype-raw@7.0.0: - resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==} - rehype-recma@1.0.0: resolution: {integrity: sha512-lqA4rGUf1JmacCNWWZx0Wv1dHqMwxzsDWYMTowuplHF3xH0N/MmrZ/G3BDZnzAkRmxDadujCjaKM2hqYdCBOGw==} @@ -2356,9 +2347,6 @@ packages: resolution: {integrity: sha512-u4J1hr6Y+C/hit34GwL3eIcUf3wngT8TlYUjK7tk0jxydKLAq3sYvifjdTDA6U3KCKRcQCQDGf/srjxfZF3l7g==} engines: {node: '>=18.12.0'} - vfile-location@5.0.4: - resolution: {integrity: sha512-vEvxatYZCIpNvzGk2UD+u4I/sZkSKoOsdRCbkOIsN73QpJbriJ1qvvBAL1PeI0y55Leoqf7pORbaSPpG/smmOg==} - vfile-message@4.0.4: resolution: {integrity: sha512-66ycRswIkNmHH9PHku7ADtv5RVwgIrOcuv3J8Svz6h4qgGRrKVa+9/neuKyJZUXyOpYwLTvS+whZ4R2urHHgQg==} @@ -2491,12 +2479,19 @@ packages: engines: {node: '>= 14.6'} hasBin: true - yuku-analyzer@0.10.2: - resolution: {integrity: sha512-UBRcDcZtIn14g88loZUZ123d6MOkc2hMTawUle5MkuWboowM90KbWHN3Zz+HfuS06sw935ygecBpcJlXHB/pOA==} + yuku-analyzer@0.19.0: + resolution: {integrity: sha512-Iu7DV5cWOQ3ERSA7oBquz/RT5IEGsUyUeCivYs9lQaZ4nSjM31yD17mH616JKcTyVoVWYivsFZ+twT3UyBosTA==} + engines: {node: '>=14.18.0'} + deprecated: 'Yuku is now one package with one core. Use "yuku" instead: https://yuku.fyi/javascript/. Existing installs keep working but get no more fixes.' + + yuku-ast@0.19.0: + resolution: {integrity: sha512-PyCsiScaelhxBGzL8dyeJkLqvRZycoh78R31Vrt/WqYrm0hMFoKwIw/X7Dx5mBKLWAMlV9I9HEyBOHnj2gZVyw==} + engines: {node: '>=14.18.0'} deprecated: 'Yuku is now one package with one core. Use "yuku" instead: https://yuku.fyi/javascript/. Existing installs keep working but get no more fixes.' - yuku-ast@0.10.2: - resolution: {integrity: sha512-UnG9mA6giglCvSErft2/40TVFX750Sj1xgwddPLpG7J7rlr/P1wPADg9G2RK+d/1tNLtRVoLdMMOMVBB9561TQ==} + yuku-core@0.19.0: + resolution: {integrity: sha512-kYK9e1XdfirNhkipzW0wmMcSWcVF/CWnuugodfVYRCUwvoBefweL9HzB96OiKEhsx78V5WbUxbJqlizMX869Qg==} + engines: {node: '>=14.18.0'} deprecated: 'Yuku is now one package with one core. Use "yuku" instead: https://yuku.fyi/javascript/. Existing installs keep working but get no more fixes.' yuku@0.28.1: @@ -2624,7 +2619,7 @@ snapshots: optionalDependencies: '@types/react': 19.3.3 - '@fumadocs/tailwind@0.1.2(tailwindcss@4.3.5)': + '@fumadocs/tailwind@0.1.5(tailwindcss@4.3.5)': optionalDependencies: tailwindcss: 4.3.5 @@ -3370,40 +3365,40 @@ snapshots: '@vitest/spy@5.1.2': {} - '@yuku-analyzer/binding-android-arm64@0.10.2': + '@yuku-core/binding-android-arm64@0.19.0': optional: true - '@yuku-analyzer/binding-darwin-arm64@0.10.2': + '@yuku-core/binding-darwin-arm64@0.19.0': optional: true - '@yuku-analyzer/binding-darwin-x64@0.10.2': + '@yuku-core/binding-darwin-x64@0.19.0': optional: true - '@yuku-analyzer/binding-freebsd-x64@0.10.2': + '@yuku-core/binding-freebsd-x64@0.19.0': optional: true - '@yuku-analyzer/binding-linux-arm-gnu@0.10.2': + '@yuku-core/binding-linux-arm-gnu@0.19.0': optional: true - '@yuku-analyzer/binding-linux-arm-musl@0.10.2': + '@yuku-core/binding-linux-arm-musl@0.19.0': optional: true - '@yuku-analyzer/binding-linux-arm64-gnu@0.10.2': + '@yuku-core/binding-linux-arm64-gnu@0.19.0': optional: true - '@yuku-analyzer/binding-linux-arm64-musl@0.10.2': + '@yuku-core/binding-linux-arm64-musl@0.19.0': optional: true - '@yuku-analyzer/binding-linux-x64-gnu@0.10.2': + '@yuku-core/binding-linux-x64-gnu@0.19.0': optional: true - '@yuku-analyzer/binding-linux-x64-musl@0.10.2': + '@yuku-core/binding-linux-x64-musl@0.19.0': optional: true - '@yuku-analyzer/binding-win32-arm64@0.10.2': + '@yuku-core/binding-win32-arm64@0.19.0': optional: true - '@yuku-analyzer/binding-win32-x64@0.10.2': + '@yuku-core/binding-win32-x64@0.19.0': optional: true '@yuku-toolchain/darwin-arm64@0.28.1': @@ -3418,7 +3413,7 @@ snapshots: '@yuku-toolchain/linux-x64@0.28.1': optional: true - '@yuku-toolchain/types@0.10.2': {} + '@yuku-toolchain/types@0.19.0': {} '@yuku-toolchain/win32-arm64@0.28.1': optional: true @@ -3464,7 +3459,7 @@ snapshots: character-reference-invalid@2.0.1: {} - chokidar@5.0.0: + chokidar@6.0.0: dependencies: readdirp: 5.1.1 @@ -3474,7 +3469,7 @@ snapshots: clsx@2.1.1: {} - cn@0.3.3: {} + cn@0.5.2: {} collapse-white-space@2.1.0: {} @@ -3626,10 +3621,10 @@ snapshots: fflate@0.4.9: {} - framer-motion@13.5.1(react-dom@19.3.1(react@19.3.1))(react@19.3.1): + framer-motion@14.14.0(react-dom@19.3.1(react@19.3.1))(react@19.3.1): dependencies: - motion-dom: 13.5.1 - motion-utils: 13.5.0 + motion-dom: 14.14.0 + motion-utils: 14.7.0 tslib: 2.9.1 optionalDependencies: react: 19.3.1 @@ -3638,15 +3633,18 @@ snapshots: fsevents@2.3.3: optional: true - fumadocs-core@16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7): + fumadocs-core@16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7): dependencies: '@fumari/image-size': 0.1.1 + acorn: 8.19.0 + acorn-jsx: 5.3.2(acorn@8.19.0) estree-util-value-to-estree: 3.5.0 github-slugger: 2.0.0 + hast-util-from-dom: 5.0.1 hast-util-to-estree: 3.1.3 - hast-util-to-jsx-runtime: 2.3.7 mdast-util-mdx: 3.0.0 - mdast-util-to-markdown: 2.2.5 + micromark: 4.0.3 + micromark-extension-gfm-table: 2.1.2 npm-to-yarn: 3.2.0 remark: 15.0.1 remark-gfm: 4.0.1 @@ -3655,7 +3653,6 @@ snapshots: shiki: 4.6.0 tinyglobby: 0.2.17 unified: 11.0.5 - unist-util-visit: 5.2.0 vfile: 6.0.3 yaml: 2.9.1 zbsearch: 4.0.4 @@ -3673,27 +3670,30 @@ snapshots: transitivePeerDependencies: - supports-color - fumadocs-mdx@15.4.5(@types/mdast@4.0.4)(@types/mdx@2.0.14)(@types/react@19.3.3)(fumadocs-core@16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react@19.3.1)(rolldown@1.3.4)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(yaml@2.9.1)): + fumadocs-mdx@15.6.4(@types/mdast@4.0.4)(@types/mdx@2.0.14)(@types/react@19.3.3)(fumadocs-core@16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react@19.3.1)(rolldown@1.3.4)(vite@8.4.0(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(yaml@2.9.1)): dependencies: '@mdx-js/mdx': 3.1.1 '@standard-schema/spec': 1.1.0 - chokidar: 5.0.0 + acorn: 8.19.0 + acorn-jsx: 5.3.2(acorn@8.19.0) + chokidar: 6.0.0 esbuild: 0.28.2 estree-util-value-to-estree: 3.5.0 - fumadocs-core: 16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7) + fumadocs-core: 16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7) github-slugger: 2.0.0 magic-string: 1.4.5 + mdast-util-from-markdown: 2.1.0 mdast-util-mdx: 3.0.0 + micromark-extension-mdxjs-esm: 3.0.0 picocolors: 1.1.1 picomatch: 4.0.7 tinyexec: 1.4.0 tinyglobby: 0.2.17 unified: 11.0.5 unist-util-remove-position: 5.0.0 - unist-util-visit: 5.2.0 vfile: 6.0.3 yaml: 2.9.1 - yuku-analyzer: 0.10.2 + yuku-analyzer: 0.19.0 zod: 4.6.7 optionalDependencies: '@types/mdast': 4.0.4 @@ -3705,10 +3705,10 @@ snapshots: transitivePeerDependencies: - supports-color - fumadocs-ui@16.15.15(@types/mdx@2.0.14)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(fumadocs-core@16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(tailwindcss@4.3.5): + fumadocs-ui@16.19.8(@types/mdx@2.0.14)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(fumadocs-core@16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(tailwindcss@4.3.5): dependencies: '@fuma-translate/react': 1.0.2(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) - '@fumadocs/tailwind': 0.1.2(tailwindcss@4.3.5) + '@fumadocs/tailwind': 0.1.5(tailwindcss@4.3.5) '@radix-ui/react-accordion': 1.3.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) '@radix-ui/react-collapsible': 1.2.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) '@radix-ui/react-dialog': 1.3.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) @@ -3720,23 +3720,22 @@ snapshots: '@radix-ui/react-slot': 1.5.0(@types/react@19.3.3)(react@19.3.1) '@radix-ui/react-tabs': 1.2.1(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) class-variance-authority: 0.7.1 - cn: 0.3.3 - fumadocs-core: 16.15.15(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7) + cn: 0.5.2 + fumadocs-core: 16.19.8(@mdx-js/mdx@3.1.1)(@tanstack/react-router@1.170.46(@types/react@19.3.3)(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(@types/estree-jsx@1.0.5)(@types/hast@3.0.5)(@types/mdast@4.0.4)(@types/react@19.3.3)(lucide-react@1.84.0(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(zod@4.6.7) lucide-react: 1.84.0(@types/react@19.3.3)(react@19.3.1) - motion: 13.5.1(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + motion: 14.14.0(react-dom@19.3.1(react@19.3.1))(react@19.3.1) next-themes: 0.4.6(react-dom@19.3.1(react@19.3.1))(react@19.3.1) react: 19.3.1 react-dom: 19.3.1(react@19.3.1) react-remove-scroll: 2.7.2(@types/react@19.3.3)(react@19.3.1) - rehype-raw: 7.0.0 scroll-into-view-if-needed: 3.2.1 shiki: 4.6.0 - unist-util-visit: 5.2.0 optionalDependencies: '@types/mdx': 2.0.14 '@types/react': 19.3.3 transitivePeerDependencies: - '@types/react-dom' + - remix - tailwindcss get-nonce@1.0.1: {} @@ -3749,37 +3748,16 @@ snapshots: graceful-fs@4.2.12: {} - hast-util-from-parse5@8.0.4: + hast-util-from-dom@5.0.1: dependencies: '@types/hast': 3.0.5 - '@types/unist': 3.0.3 - devlop: 1.1.0 hastscript: 9.0.3 - property-information: 7.2.0 - vfile: 6.0.3 - vfile-location: 5.0.4 web-namespaces: 2.0.1 hast-util-parse-selector@4.0.0: dependencies: '@types/hast': 3.0.5 - hast-util-raw@9.2.1: - dependencies: - '@types/hast': 3.0.5 - '@types/unist': 3.0.3 - '@ungap/structured-clone': 1.4.0 - hast-util-from-parse5: 8.0.4 - hast-util-to-parse5: 8.0.1 - html-void-elements: 3.0.0 - mdast-util-to-hast: 13.2.2 - parse5: 8.1.1 - unist-util-position: 5.0.0 - unist-util-visit: 5.2.0 - vfile: 6.0.3 - web-namespaces: 2.0.1 - zwitch: 2.0.4 - hast-util-to-estree@3.1.3: dependencies: '@types/estree': 1.0.11 @@ -3835,16 +3813,6 @@ snapshots: transitivePeerDependencies: - supports-color - hast-util-to-parse5@8.0.1: - dependencies: - '@types/hast': 3.0.5 - comma-separated-tokens: 2.0.3 - devlop: 1.1.0 - property-information: 7.2.0 - space-separated-tokens: 2.0.2 - web-namespaces: 2.0.1 - zwitch: 2.0.4 - hast-util-whitespace@3.0.0: dependencies: '@types/hast': 3.0.5 @@ -4419,15 +4387,15 @@ snapshots: transitivePeerDependencies: - supports-color - motion-dom@13.5.1: + motion-dom@14.14.0: dependencies: - motion-utils: 13.5.0 + motion-utils: 14.7.0 - motion-utils@13.5.0: {} + motion-utils@14.7.0: {} - motion@13.5.1(react-dom@19.3.1(react@19.3.1))(react@19.3.1): + motion@14.14.0(react-dom@19.3.1(react@19.3.1))(react@19.3.1): dependencies: - framer-motion: 13.5.1(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + framer-motion: 14.14.0(react-dom@19.3.1(react@19.3.1))(react@19.3.1) tslib: 2.9.1 optionalDependencies: react: 19.3.1 @@ -4588,12 +4556,6 @@ snapshots: dependencies: regex-utilities: 2.3.0 - rehype-raw@7.0.0: - dependencies: - '@types/hast': 3.0.5 - hast-util-raw: 9.2.1 - vfile: 6.0.3 - rehype-recma@1.0.0: dependencies: '@types/estree': 1.0.11 @@ -4899,11 +4861,6 @@ snapshots: verkit@0.5.0: {} - vfile-location@5.0.4: - dependencies: - '@types/unist': 3.0.3 - vfile: 6.0.3 - vfile-message@4.0.4: dependencies: '@types/unist': 3.0.3 @@ -4981,27 +4938,32 @@ snapshots: yaml@2.9.1: {} - yuku-analyzer@0.10.2: + yuku-analyzer@0.19.0: + dependencies: + '@yuku-toolchain/types': 0.19.0 + yuku-ast: 0.19.0 + yuku-core: 0.19.0 + + yuku-ast@0.19.0: + dependencies: + '@yuku-toolchain/types': 0.19.0 + + yuku-core@0.19.0: dependencies: - '@yuku-toolchain/types': 0.10.2 - yuku-ast: 0.10.2 + '@yuku-toolchain/types': 0.19.0 optionalDependencies: - '@yuku-analyzer/binding-android-arm64': 0.10.2 - '@yuku-analyzer/binding-darwin-arm64': 0.10.2 - '@yuku-analyzer/binding-darwin-x64': 0.10.2 - '@yuku-analyzer/binding-freebsd-x64': 0.10.2 - '@yuku-analyzer/binding-linux-arm-gnu': 0.10.2 - '@yuku-analyzer/binding-linux-arm-musl': 0.10.2 - '@yuku-analyzer/binding-linux-arm64-gnu': 0.10.2 - '@yuku-analyzer/binding-linux-arm64-musl': 0.10.2 - '@yuku-analyzer/binding-linux-x64-gnu': 0.10.2 - '@yuku-analyzer/binding-linux-x64-musl': 0.10.2 - '@yuku-analyzer/binding-win32-arm64': 0.10.2 - '@yuku-analyzer/binding-win32-x64': 0.10.2 - - yuku-ast@0.10.2: - dependencies: - '@yuku-toolchain/types': 0.10.2 + '@yuku-core/binding-android-arm64': 0.19.0 + '@yuku-core/binding-darwin-arm64': 0.19.0 + '@yuku-core/binding-darwin-x64': 0.19.0 + '@yuku-core/binding-freebsd-x64': 0.19.0 + '@yuku-core/binding-linux-arm-gnu': 0.19.0 + '@yuku-core/binding-linux-arm-musl': 0.19.0 + '@yuku-core/binding-linux-arm64-gnu': 0.19.0 + '@yuku-core/binding-linux-arm64-musl': 0.19.0 + '@yuku-core/binding-linux-x64-gnu': 0.19.0 + '@yuku-core/binding-linux-x64-musl': 0.19.0 + '@yuku-core/binding-win32-arm64': 0.19.0 + '@yuku-core/binding-win32-x64': 0.19.0 yuku@0.28.1: optionalDependencies: diff --git a/src/components/docs-header.tsx b/src/components/docs-header.tsx index e8fc41a..81aa3cc 100644 --- a/src/components/docs-header.tsx +++ b/src/components/docs-header.tsx @@ -83,8 +83,8 @@ const DRAWER = '#nd-sidebar-mobile'; // Focus follows the drawer, as it does in the landing menu: into it when it // opens, to the current page or else the first link, and back to the menu // button when it closes with focus still inside it or lost. The drawer mounts a -// frame after `open` changes, so the link is looked up then. Escape closes it: -// Fumadocs 16.15 has no handler, and a later one that also closes it is harmless. +// frame after `open` changes, so the link is looked up then. Escape closes it +// from anywhere on the page; Fumadocs' own handler also closing it is harmless. function useDrawerFocus(open: boolean, toggle: RefObject, close: () => void) { const opened = useRef(false); const closeRef = useRef(close); diff --git a/src/components/page-actions.test.tsx b/src/components/page-actions.test.tsx index fe0e38d..812debc 100644 --- a/src/components/page-actions.test.tsx +++ b/src/components/page-actions.test.tsx @@ -29,7 +29,7 @@ afterEach(() => { describe('the Copy Markdown button', () => { it('is named Copy Markdown, and says Copied Markdown in a polite live region once it has copied, at every width', async () => { - vi.stubGlobal('fetch', async () => ({ text: async () => '# A page' })); + vi.stubGlobal('fetch', async () => ({ ok: true, text: async () => '# A page' })); vi.stubGlobal('ClipboardItem', class { constructor(readonly items: unknown) {} }); const write = vi.fn(async () => {}); Object.defineProperty(navigator, 'clipboard', { value: { write, writeText: write }, configurable: true }); diff --git a/src/config.ts b/src/config.ts index 97c2254..5794c10 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ export { codeOptions } from './lib/code-options'; -export { attributeOf, isJsx, llmsOptions } from './lib/llms'; -export type { JsxElement, LlmsConfig, Rewrite, RewriteContext } from './lib/llms'; +export { attributeOf, isJsx, llmsCopy } from './lib/llms'; +export type { JsxElement, LlmsConfig, LlmsCopy, Rewrite, RewriteContext } from './lib/llms'; export { labelTable, rehypeTableLabels } from './lib/table-labels'; export type { HastNode } from './lib/table-labels'; diff --git a/src/lib/llms.test.ts b/src/lib/llms.test.ts index c4a0dcc..f3e7120 100644 --- a/src/lib/llms.test.ts +++ b/src/lib/llms.test.ts @@ -1,18 +1,23 @@ import { remarkLLMs } from 'fumadocs-core/mdx-plugins/remark-llms'; +import { applyMdxPreset, remarkInclude } from 'fumadocs-mdx/config'; +import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import path from 'node:path'; import remarkGfm from 'remark-gfm'; import remarkMdx from 'remark-mdx'; import remarkParse from 'remark-parse'; -import { unified } from 'unified'; -import { describe, expect, it } from 'vitest'; -import { llmsOptions, type LlmsConfig } from './llms'; +import { unified, type Plugin } from 'unified'; +import { afterAll, describe, expect, it } from 'vitest'; +import { llmsCopy, type LlmsConfig } from './llms'; /** The Markdown copy of an MDX page, as the build writes it. */ -async function copy(mdx: string, config?: LlmsConfig): Promise { - const processor = unified() - .use(remarkParse) - .use(remarkMdx) - .use(remarkGfm) - .use(remarkLLMs, { ...llmsOptions(config), _data: true, headingIds: false }) +async function copy(mdx: string, config?: LlmsConfig, before: Plugin[] = []): Promise { + const llms = llmsCopy(config); + const processor = unified().use(remarkParse).use(remarkMdx).use(remarkGfm); + for (const plugin of before) processor.use(plugin as never); + processor + .use(llms.plugin) + .use(remarkLLMs, { ...llms.options, _data: true, headingIds: false }) .use(function () { this.compiler = () => ''; }); @@ -39,6 +44,7 @@ describe('the components the kit knows', () => { expect(await copy('\n\nBegin here.\n\n')).toBe('- [Start](/start): Begin here.'); expect(await copy('\nBecause.\n')).toBe('**Why**\n\nBecause.'); expect(await copy('\nBe careful.\n')).toBe('> **Note.** Be careful.'); + expect(await copy('\n```sh\nexample run\n```\n')).toBe('> **Note.**\n>\n> ```sh\n> example run\n> ```'); }); it('writes a terminal as its command, then its output under a label', async () => { @@ -60,7 +66,7 @@ describe('a component the kit does not know', () => { it('leaves it out when it has no label', async () => { const text = await copy('Before.\n\n\n\nAfter.'); expect(text).not.toContain('Diagram'); - expect(text.replace(/\s+/g, ' ')).toBe('Before. After.'); + expect(text).toBe('Before.\n\nAfter.'); }); }); @@ -132,3 +138,349 @@ describe('a fenced block with notation comments', () => { expect(text).toBe('```sh\nexample run\n```\n\nOutput:\n\n```text\ndone\n```'); }); }); + +describe('a page written the way the copy reads it', () => { + it('keeps a rewrite inside a list item and a quote under their markers', async () => { + expect(await copy('- item\n\n \n Be careful.\n\n Second.\n \n')).toBe('- item\n\n > **Note.** Be careful.\n >\n > Second.'); + expect(await copy('> \n> Quote.\n> ')).toBe('> > **Note.** Quote.'); + }); + + it('writes a fenced block in a list item under the list', async () => { + expect(await copy('- list\n\n ```ts\n a // [!code ++]\n ```')).toBe('- list\n\n ```ts\n a\n ```'); + }); + + it('writes a fence that holds a fence with a longer one', async () => { + expect(await copy('````md title="Page" note="Shown"\n```ts\ninner\n```\n````')).toBe('Page (Shown):\n\n````md\n```ts\ninner\n```\n````'); + }); + + it('writes components nested in each other, and one written on a line of text', async () => { + const text = await copy('\n\n### One\n\n\n\nA text\n\n\n\n'); + expect(text).toBe('### One\n\n**a**\n\nA text'); + expect(await copy('See the *body* now.')).toBe('See - [c](/h): the *body* now.'); + }); + + it('writes a padded table without padding, and keeps the alignment of its columns', async () => { + expect(await copy('| A | B |\n| ---- | ---- |\n| padded | x |')).toBe('| A | B |\n| - | - |\n| padded | x |'); + expect(await copy('| A | B | C |\n| :-- | :-: | --: |\n| 1 | 2 | 3 |')).toBe('| A | B | C |\n| :- | :-: | -: |\n| 1 | 2 | 3 |'); + }); + + it('writes a component in a table cell as the cell\'s text', async () => { + const text = await copy('| A | B |\n| - | - |\n| x | |'); + expect(text).toBe('| A | B |\n| - | - |\n| x | Figure: Shown. |'); + }); + + it('leaves out the imports of a page and keeps its other text', async () => { + expect(await copy('import X from "./x"\n\nBefore.')).toBe('Before.'); + }); +}); + +const folders: string[] = []; + +afterAll(async () => { + await Promise.all(folders.map((folder) => rm(folder, { recursive: true, force: true }))); +}); + +/** + * The copy as the site's build makes it, in the order of Fumadocs's own loader: + * the includes, the preset's plugins, the kit's, then the copy. `files` are + * written next to the page, which is at `content/page.mdx` under the site's folder. + */ +async function built(mdx: string, config?: LlmsConfig, files: Record = {}): Promise { + const site = await mkdtemp(path.join(tmpdir(), 'docs-kit-llms-')); + folders.push(site); + for (const [name, content] of Object.entries(files)) { + await mkdir(path.dirname(path.join(site, name)), { recursive: true }); + await writeFile(path.join(site, name), content); + } + const llms = llmsCopy(config); + const options = await applyMdxPreset({ remarkPlugins: (plugins) => [...plugins, llms.plugin] })('bundler'); + const processor = unified().use(remarkParse).use(remarkMdx).use(remarkInclude); + for (const plugin of options.remarkPlugins ?? []) { + if (Array.isArray(plugin)) processor.use(plugin[0] as never, plugin[1] as never); + else processor.use(plugin as never); + } + processor + .use(remarkLLMs, { ...llms.options, _data: true }) + .use(function () { + this.compiler = () => ''; + }); + const file = await processor.process({ value: mdx, path: path.join(site, 'content/page.mdx'), cwd: site }); + return String(file.data.markdown).trim(); +} + +describe('through the Fumadocs preset', () => { + // A page that holds every rewrite the kit makes, a fenced block with a header, + // notation and a table. An update to fumadocs-core that drops one makes this fail. + const page = [ + '# Setup', + '', + '', + 'Back up first.', + '', + '', + '', + '', + '### Install', + '', + '', + '', + '```sh', + 'npm install example # [!code highlight]', + '```', + '', + '', + '```sh', + 'pnpm add example', + '```', + '', + '', + '', + '', + '', + '', + '', + 'Begin here.', + '', + '', + '', + '', + '', + 'Because.', + '', + '', + '', + '', + '```sh', + 'example run', + '```', + '', + '```text', + 'done', + '```', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '```json title="Response" status="200"', + '{} // [!code ++]', + '```', + '', + '| Name | Meaning |', + '| ---------- | ------------- |', + '| `a` | The first setting. |', + ].join('\n'); + + it('writes every rewrite and header of the kit, and an unpadded table', async () => { + expect(await built(page)).toBe( + [ + '# Setup [#setup]', + '', + '> **Note.** Back up first.', + '', + '### Install [#install]', + '', + '**npm**', + '', + '```sh', + 'npm install example', + '```', + '', + '**pnpm**', + '', + '```sh', + 'pnpm add example', + '```', + '', + '- [Start](/start): Begin here.', + '', + '**Why**', + '', + 'Because.', + '', + '```sh', + 'example run', + '```', + '', + 'Output:', + '', + '```text', + 'done', + '```', + '', + '```text', + 'src/', + ' a.ts', + '```', + '', + 'Figure: Two servers share one library.', + '', + 'Response (200 OK):', + '', + '```json', + '{}', + '```', + '', + '| Name | Meaning |', + '| - | - |', + '| `a` | The first setting. |', + ].join('\n'), + ); + }); + + it('writes a site\'s own rewrite', async () => { + expect(await built('Use to open it.', { rewrites: { Icon: ({ attribute }) => `the ${attribute('name')} icon` } })).toBe( + 'Use the gear icon to open it.', + ); + }); +}); + +describe('a page that includes another file', () => { + // The way the docs site includes generated files: a table, a heading and a + // fenced block, in a file the page names. + const files = { + 'content/shared/fields.md': [ + '## Fields', + '', + '| Field | Meaning |', + '| ------- | ------------- |', + '| `name` | What it is. |', + '', + '```sh title="Run" status="200"', + 'example run # [!code highlight]', + '```', + '', + ].join('\n'), + 'src/generated/jobs.md': ['| Job | Runs |', '| --- | --- |', '| `sweep` | Daily. |', ''].join('\n'), + 'content/shared/snippet.ts': 'export const a = 1;\n', + }; + + it('writes the included content in place of the tag, with every rewrite applied', async () => { + const page = [ + '# Page', + '', + 'Some text before the include, long enough to push the include well past the start of the file.', + '', + './shared/fields.md', + '', + 'After the include.', + ].join('\n'); + expect(await built(page, undefined, files)).toBe( + [ + '# Page [#page]', + '', + 'Some text before the include, long enough to push the include well past the start of the file.', + '', + '## Fields [#fields]', + '', + '| Field | Meaning |', + '| - | - |', + '| `name` | What it is. |', + '', + 'Run (200 OK):', + '', + '```sh', + 'example run', + '```', + '', + 'After the include.', + ].join('\n'), + ); + }); + + it('resolves an include from the site folder with `cwd`, and keeps the text around it intact', async () => { + const page = ['# Page', '', 'Jobs:', '', 'src/generated/jobs.md', '', 'Then more text, which must not be cut or moved.'].join('\n'); + expect(await built(page, undefined, files)).toBe( + ['# Page [#page]', '', 'Jobs:', '', '| Job | Runs |', '| - | - |', '| `sweep` | Daily. |', '', 'Then more text, which must not be cut or moved.'].join('\n'), + ); + }); + + it('writes an include inside a component, and a file that is not Markdown as a fenced block', async () => { + const page = ['', './shared/snippet.ts', '', '', '', '', 'src/generated/jobs.md', '', ''].join('\n'); + expect(await built(page, undefined, files)).toBe( + ['> **Note.**', '>', '> ```ts', '> export const a = 1;', '> ```', '', '| Job | Runs |', '| - | - |', '| `sweep` | Daily. |'].join('\n'), + ); + }); + + it('writes components of an included file, and two includes of one file', async () => { + const withTabs = { + 'content/shared/tabs.mdx': '\n\nIn the include.\n\n\n', + }; + const page = ['./shared/tabs.mdx', '', 'Between.', '', './shared/tabs.mdx'].join('\n'); + expect(await built(page, undefined, withTabs)).toBe(['**a**', '', 'In the include.', '', 'Between.', '', '**a**', '', 'In the include.'].join('\n')); + }); +}); + +describe('a node another plugin adds', () => { + // A site plugin that puts an icon, which has no place in the source, in a table cell. + type Cell = { type: string; children: { type: string; value?: string }[] }; + const icons = () => (tree: { children: { type: string; children?: { children?: Cell[] }[] }[] }): void => { + for (const table of tree.children.filter((node) => node.type === 'table')) { + for (const row of table.children ?? []) { + for (const cell of row.children ?? []) { + const [first] = cell.children; + if (first?.type === 'inlineCode') { + cell.children = [ + { type: 'mdxJsxTextElement', name: 'Icon', attributes: [{ type: 'mdxJsxAttribute', name: 'markdown', value: first.value }], children: [] } as never, + ]; + } + } + } + } + }; + const config: LlmsConfig = { rewrites: { Icon: ({ attribute }) => attribute('markdown') ?? '' } }; + + it('writes a table cell from what its children are written as', async () => { + const text = await copy('| Mark | Name |\n| - | - |\n| `lucide:ticket` | Tickets |', config, [icons as unknown as Plugin]); + expect(text).toBe('| Mark | Name |\n| - | - |\n| lucide:ticket | Tickets |'); + }); +}); + +describe('a code block that is a tab', () => { + it('writes the tab as a label, then the fence without its tab attributes', async () => { + const page = ['```http tab="Code flow"', 'POST /oauth/register', '```', '', '```http tab="Device flow"', 'POST /oauth/device', '```'].join('\n'); + expect(await built(page)).toBe( + ['**Code flow**', '', '```http', 'POST /oauth/register', '```', '', '**Device flow**', '', '```http', 'POST /oauth/device', '```'].join('\n'), + ); + }); + + it('drops tab-group too, and keeps a title, a note and the notation rewrites', async () => { + const page = [ + '```bash tab="CLI" tab-group="client" title="Run" note="Needs a key"', + 'marfa items list # [!code highlight]', + '```', + '', + '```ts tab="TypeScript" tab-group="client"', + 'await items.list();', + '```', + ].join('\n'); + expect(await built(page)).toBe( + ['**CLI**', '', 'Run (Needs a key):', '', '```bash', 'marfa items list', '```', '', '**TypeScript**', '', '```ts', 'await items.list();', '```'].join('\n'), + ); + }); + + it('writes the label once for a tab of several blocks, and writes a tab in a list item', async () => { + const page = ['```sh tab="One"', 'a', '```', '', '```sh tab="One"', 'b', '```', '', '- item', '', ' ```sh tab="In list"', ' c', ' ```'].join('\n'); + expect(await built(page)).toBe( + ['**One**', '', '```sh', 'a', '```', '', '```sh', 'b', '```', '', '- item', '', ' **In list**', '', ' ```sh', ' c', ' ```'].join('\n'), + ); + }); + + it('writes a tab in an included file', async () => { + const files = { 'content/shared/tabs.md': '```sh tab="Included"\nrun\n```\n' }; + expect(await built('Before.\n\n./shared/tabs.md', undefined, files)).toBe('Before.\n\n**Included**\n\n```sh\nrun\n```'); + }); + + it('keeps the fence as authored where Fumadocs writes the install tabs itself', async () => { + // remarkNpm replaces the block with one tab per package manager and pins the + // authored block as the page's source; the copy keeps that block. + expect(await built('```npm\nnpm install example\n```')).toBe('```npm\nnpm install example\n```'); + }); +}); diff --git a/src/lib/llms.ts b/src/lib/llms.ts index 9ab25b0..af3f9db 100644 --- a/src/lib/llms.ts +++ b/src/lib/llms.ts @@ -1,6 +1,6 @@ import { parseCodeBlockAttributes } from 'fumadocs-core/mdx-plugins'; import type { LLMsOptions } from 'fumadocs-core/mdx-plugins/remark-llms'; -import { gfmTableToMarkdown } from 'mdast-util-gfm-table'; +import { replaceSource, type Stringifier } from 'fumadocs-core/mdx-plugins/stringifier'; import { statusLabel } from './http-status'; /** The part of an MDX JSX node the Markdown copy reads (mdast-util-mdx's shape). */ @@ -94,7 +94,9 @@ const REWRITES: Record = { return `- [${attribute('title') ?? ''}](${attribute('href') ?? ''})${text ? `: ${text}` : ''}`; }, Callout: ({ attribute, inner }) => { - const body = `**${attribute('title') ?? ''}.** ${inner()}`; + const text = inner(); + // A fence must open its own line, or the copy loses the code block. + const body = `**${attribute('title') ?? ''}.**${/^(```|~~~)/.test(text) ? '\n\n' : ' '}${text}`; return body .split('\n') .map((line) => (line ? `> ${line}` : '>')) @@ -130,70 +132,208 @@ export function stripNotation(code: string): string { /** Elements the copy keeps in the tree although it never writes them itself: `Files` reads them. */ const KEPT = ['Folder', 'File']; +/** A node of the tree the plugin walks. */ +type Tree = { type: string; children?: Tree[] }; +type Source = Parameters[0]; +type Node = Parameters[1]; + /** - * The options of the Markdown copy of each page, which agents read at - * `.md`, through a docs MCP server and in `llms-full.txt`. Give them to - * `defineDocs({ docs: { postprocess: { includeProcessedMarkdown: llmsOptions() } } })`. + * A fenced block as Markdown: the fence is longer than any run of its own + * character in the code, and uses tildes when the info string holds a backtick. + */ +function fence(lang: string | null | undefined, meta: string, value: string): string { + const info = [lang, meta].filter(Boolean).join(' '); + const marker = info.includes('`') ? '~' : '`'; + const longest = Math.max(0, ...[...value.matchAll(new RegExp(`${marker}+`, 'g'))].map((run) => run[0].length)); + const bar = marker.repeat(Math.max(3, longest + 1)); + return `${bar}${info}\n${value}\n${bar}`; +} + +/** The Markdown a fenced block is copied as, or `undefined` when its source already is that. */ +function codeCopy(node: Tree & { lang?: string | null; meta?: string | null; value: string; data?: { tab?: unknown } }): string | undefined { + const clean = stripNotation(node.value); + // `remarkCodeTab` reads `tab=` and `tab-group=` off the block into a tab around + // it, which the copy writes as a label; the page's source still holds them. + const tabbed = typeof node.data?.tab === 'string'; + const meta = parseCodeBlockAttributes(node.meta ?? '', ['tab', 'tab-group']).rest.trim(); + // A note or a status chip in the header: its words come first, so an agent + // loses nothing the page shows. + const { rest, attributes } = parseCodeBlockAttributes(meta, ['title', 'note', 'status']); + const extra = + typeof attributes.note === 'string' + ? attributes.note + : attributes.status != null + ? statusLabel(String(attributes.status)) + : undefined; + if (extra === undefined) return clean === node.value && !tabbed ? undefined : fence(node.lang, meta, clean); + const label = typeof attributes.title === 'string' ? `${attributes.title} (${extra})` : extra; + return `${label}:\n\n${fence(node.lang, rest.trim(), clean)}`; +} + +/** The delimiter row cell of a column: as short as it can be, keeping its alignment. */ +function delimiter(align: string | null | undefined): string { + return align === 'center' ? ':-:' : align === 'left' ? ':-' : align === 'right' ? '-:' : '-'; +} + +/** Whether a node has a place in the page's source, which a node a plugin adds lacks. */ +function placed(node: Tree): boolean { + const { position } = node as { position?: { start: { offset?: number }; end: { offset?: number } } }; + return position?.start.offset !== undefined && position.end.offset !== undefined; +} + +/** The first and last nodes under a node that have a place in the source, looking through the nodes that have none. */ +function ends(node: Tree): [Tree, Tree] | undefined { + const spans = (node.children ?? []).flatMap((child) => (placed(child) ? [[child, child] as [Tree, Tree]] : (ends(child) ?? []))); + return spans.length ? [spans[0][0], spans[spans.length - 1][1]] : undefined; +} + +/** Stands for an element's content in the text its rewrite makes, to tell that text from the content. */ +const CONTENT = '\0'; + +/** + * A table with each cell as it is written, in the form the Markdown copy uses: + * padding every cell to its column's width would make the copies, and so + * llms-full.txt, about a fifth spaces and dashes. + */ +function tableCopy(node: Tree & { align?: (string | null)[] }, cell: (cell: Tree) => string): string { + const rows = (node.children ?? []).map((row) => (row.children ?? []).map((item) => cell(item).replace(/\s*\n\s*/g, ' ').trim())); + const line = (cells: string[]) => `| ${cells.join(' | ')} |`; + const [header = [], ...body] = rows; + return [line(header), line(header.map((_, i) => delimiter(node.align?.[i]))), ...body.map(line)].join('\n'); +} + +/** The two parts of a site's Markdown copy, which are used together. */ +export interface LlmsCopy { + /** + * Give them to `defineDocs({ docs: { postprocess: { includeProcessedMarkdown: llms.options } } })`. + * They ask for the Markdown as text, so the plugin's edits are what a page is copied as. + */ + options: LLMsOptions; + /** + * The remark plugin that writes the copy. Add it to the site's `remarkPlugins` + * in `defineConfig({ mdxOptions })`, so that it runs before the copy is made. + */ + plugin: () => (tree: Tree, file: Source) => void; +} + +/** + * The Markdown copy of each page, which agents read at `.md`, through a + * docs MCP server and in `llms-full.txt`. Fumadocs writes the copy from the + * page's own source, so the copy of a component, a fenced block and a table + * is an edit to that source, made by a remark plugin before Fumadocs writes it. * * Layout components give way to their content, a few become plain Markdown, and * the visuals are left out: a page's prose carries every fact a visual shows. A * component the copy does not know, given a `label`, is written as that label * on a "Figure:" line. + * + * A node another plugin adds, such as the tab Fumadocs makes around a block + * with `tab=`, has no place in the source and so cannot be edited. The copy + * writes what its rewrite puts around its content as an edit to the first and + * last nodes inside it that do. */ -export function llmsOptions(config: LlmsConfig = {}): LLMsOptions { +export function llmsCopy(config: LlmsConfig = {}): LlmsCopy { const wrappers = new Set([...WRAPPERS, ...(config.wrappers ?? [])]); const rewrites = { ...REWRITES, ...config.rewrites }; - const rewritten = new Set([...Object.keys(rewrites), ...KEPT]); - - return { - // Tables without column alignment: padding each cell to its column's width - // would make the copies, and so llms-full.txt, about a fifth spaces and - // dashes. A later extension's handlers replace remark-gfm's. - extensions: [gfmTableToMarkdown({ tablePipeAlign: false })], - filterElement(node) { - if (!isJsx(node) || !node.name) return true; - if (rewritten.has(node.name)) return true; - if (wrappers.has(node.name)) return 'children-only'; - return attributeOf(node, 'label') !== undefined; - }, - stringify(node, parent, state, info) { - // A fenced block with a note or a status chip in its header: the header's - // words come first, so an agent loses nothing the page shows. - if (node.type === 'code') { - const code = node as unknown as { meta?: string | null }; - const clean = stripNotation(node.value as string); - const bare = clean === node.value ? node : { ...node, value: clean }; - const { rest, attributes } = parseCodeBlockAttributes(code.meta ?? '', ['title', 'note', 'status']); - const extra = - typeof attributes.note === 'string' - ? attributes.note - : attributes.status != null - ? statusLabel(String(attributes.status)) - : undefined; - if (extra === undefined) return bare === node ? undefined : state.handle(bare as never, parent as never, state, info); - const label = typeof attributes.title === 'string' ? `${attributes.title} (${extra})` : extra; - const fence = state.handle({ ...bare, meta: rest.trim() || null } as never, parent as never, state, info); - return `${label}:\n\n${fence}`; - } - if (!isJsx(node) || !node.name) return undefined; - const rewrite = rewrites[node.name]; - if (!rewrite) { - const label = wrappers.has(node.name) ? undefined : attributeOf(node, 'label'); - return label === undefined ? undefined : `Figure: ${label}`; + const rewriteOf = (name: string) => (Object.hasOwn(rewrites, name) ? rewrites[name] : undefined); + const known = (name: string) => rewriteOf(name) !== undefined || wrappers.has(name); + + /** The Markdown of a node: its source, or for a node another plugin added, what it is written as. */ + const copyOf = (node: Tree, s: Stringifier): string => { + if (placed(node)) return s.stringify(node as Node); + if (isJsx(node)) return render(contextOf(node, s)); + const { value } = node as { value?: unknown }; + if (typeof value === 'string') return node.type === 'inlineCode' ? `\`${value}\`` : value; + return (node.children ?? []).map((child) => copyOf(child, s)).join(''); + }; + + /** The nodes as Markdown blocks. */ + const flow = (children: Tree[], s: Stringifier): string => + children + .map((child) => copyOf(child, s)) + .filter(Boolean) + .join('\n\n') + .trim(); + + /** What a component's rewrite is given, over the source the copy is written from. */ + const contextOf = (node: JsxElement, s: Stringifier): RewriteContext => ({ + node, + attribute: (name) => attributeOf(node, name), + // A component written on one line holds phrasing, not paragraphs, and + // writing that as blocks would break the text at each inline element. + inner: () => + node.children.some((child) => FLOW.has(child.type)) + ? flow(node.children as Tree[], s) + : placed(node) + ? s.inner(node as Node).trim() + : (node.children as Tree[]).map((child) => copyOf(child, s)).join('').trim(), + flow: (children) => flow(children as Tree[], s), + }); + + /** The Markdown a component is copied as. */ + const render = (context: RewriteContext): string => { + const name = context.node.name ?? ''; + const rewrite = rewriteOf(name); + if (rewrite) return rewrite(context); + if (wrappers.has(name)) return context.inner(); + const label = context.attribute('label'); + return label === undefined ? '' : `Figure: ${label}`; + }; + + /** The text an element's rewrite writes before and after its content, when it writes the content once. */ + const framing = (node: JsxElement): [string, string] | undefined => { + const parts = render({ node, attribute: (name) => attributeOf(node, name), inner: () => CONTENT, flow: () => CONTENT }).split(CONTENT); + return parts.length === 2 && (parts[0] || parts[1]) ? [parts[0], parts[1]] : undefined; + }; + + const plugin = () => (tree: Tree, file: Source) => { + /** The text to write around the copy of a node, for the elements another plugin put around it. */ + const around = new Map(); + const edit = (node: Tree, text: string | ((s: Stringifier) => string)) => { + const frame = around.get(node); + around.delete(node); + const write = (s: Stringifier) => (typeof text === 'string' ? text : text(s)); + replaceSource(file, node as Node, frame ? (s) => frame.before + write(s) + frame.after : text, 'markdown'); + }; + + const visit = (node: Tree) => { + const element = isJsx(node) && node.name && !KEPT.includes(node.name) ? node : undefined; + if (element && placed(node)) { + edit(node, (s) => render(contextOf(element, s))); + } else if (element) { + // Another plugin added this element, so it has no place in the source to edit: + // the text its rewrite puts around the content goes around the nodes inside that do. + const span = known(element.name!) ? ends(node) : undefined; + const text = span && framing(element); + if (span && text) { + const [first, last] = span; + const start = around.get(first) ?? { before: '', after: '' }; + around.set(first, { before: start.before + text[0], after: start.after }); + const end = around.get(last) ?? { before: '', after: '' }; + around.set(last, { before: end.before, after: text[1] + end.after }); + } + } else if (node.type === 'code' && placed(node)) { + const text = codeCopy(node as Parameters[0]); + if (text !== undefined) edit(node, text); + } else if (node.type === 'table' && placed(node)) { + edit(node, (s) => + tableCopy(node, (cell) => + // A cell holding a node another plugin added is written from its children, as its source lacks them. + (cell.children ?? []).some((child) => !placed(child)) + ? (cell.children ?? []).map((child) => copyOf(child, s)).join('') + : s.inner(cell as Node), + ), + ); } - // A component written on one line holds phrasing, not paragraphs, and - // writing that as flow would break the text at each inline element. - const inline = node.children.every((child) => !FLOW.has(child.type)); - return rewrite({ - node, - attribute: (name) => attributeOf(node, name), - inner: () => - (inline - ? state.containerPhrasing({ type: 'paragraph', children: node.children } as never, info) - : state.containerFlow(node as never, info) - ).trim(), - flow: (children) => state.containerFlow({ type: 'root', children } as never, info).trim(), - }); - }, + for (const child of node.children ?? []) visit(child); + // A node that starts or ends such an element and was not edited above still takes the text around it. + if (around.has(node) && placed(node)) edit(node, (s) => s.stringify(node as Node)); + }; + visit(tree); }; + + // `output: 'string'` keeps the copy a string written when the page is built, + // which Fumadocs does not do for a content source that renders pages for + // props, where a component's own Markdown form would replace these edits. + return { options: { output: 'string' }, plugin }; } diff --git a/src/lib/translations.test.ts b/src/lib/translations.test.ts index 6cbf7e5..a247fff 100644 --- a/src/lib/translations.test.ts +++ b/src/lib/translations.test.ts @@ -10,7 +10,7 @@ async function packageKeys(): Promise { ( await import( /* @vite-ignore */ new URL( - `../../node_modules/${name}/.translations/keys.js`, + `../../node_modules/${name}/.translations/keys.json.js`, import.meta.url, ).href ) diff --git a/src/lib/translations.ts b/src/lib/translations.ts index 848d856..c5871fb 100644 --- a/src/lib/translations.ts +++ b/src/lib/translations.ts @@ -1,10 +1,10 @@ // Fumadocs prints its labels in title case, and the style guide asks for // sentence case. A key is the label's English text followed by its context in -// brackets, as listed in `.translations/keys.js` in `fumadocs-ui`, and a value +// brackets, as listed in `.translations/keys.json.js` in `fumadocs-ui`, and a value // replaces the whole label. A site adds the labels of other Fumadocs packages // it uses to this map. export const translations: Record = { - 'Back to Home(404 page)': 'Back to home', + 'Back to Home(404 not found page)': 'Back to home', 'Close Banner(banner)(aria-label)': 'Close banner', 'Close Search(search dialog)(aria-label)': 'Close search', 'Close Sidebar(aria-label)': 'Close sidebar', @@ -17,15 +17,19 @@ export const translations: Record = { 'Copy Link(accordion)(aria-label)': 'Copy link', 'Copy Text(code block)(aria-label)': 'Copy text', 'Hide Sidebar(sidebar)': 'Hide sidebar', + 'Image Viewer(image zoom)(aria-label)': 'Image viewer', 'Layout Tab(layout tab trigger)': 'Layout tab', + 'Next Image(image zoom)(aria-label)': 'Next image', 'Next Page(pagination)': 'Next page', 'No Headings(table of contents)': 'No headings', 'Open Search(search trigger)(aria-label)': 'Open search', 'Open Sidebar(sidebar)(aria-label)': 'Open sidebar', - 'Page Not Found(404 page)': 'Page not found', + 'Page Not Found(404 not found page)': 'Page not found', + 'Previous Image(image zoom)(aria-label)': 'Previous image', 'Previous Page(pagination)': 'Previous page', 'Show Sidebar(sidebar)': 'Show sidebar', + 'Skip to Content(skip link)': 'Skip to content', 'Table of Contents(inline table of contents)': 'Table of contents', - 'Toggle Menu(mobile menu)(aria-label)': 'Toggle menu', + 'Toggle Menu(home layout header)(aria-label)': 'Toggle menu', 'Toggle Theme(theme switcher)(aria-label)': 'Toggle theme', };