Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(react): give llms-txt-full a Markdown pipeline
#1157 removed `@doc-kit/core/utils/remark.mjs`, which `llms-txt-full`
(#1127) still imported, so loading the generator failed on main.

The generator now declares its own `markdown` pipeline and serialises
pages with `getProcessor('llms-txt-full')`, as `json` does. The pipeline
names `remark-gfm` and `remark-stringify`, so the react package depends
on them directly.

Assisted-by: Claude Sonnet 5.5 <noreply@anthropic.com>
  • Loading branch information
ovflowd committed Oct 10, 2026
commit 43a9c35ecd3c8b0e6289bad8aa075a3ea1e939f6
2 changes: 2 additions & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@
"recma-stringify": "^1.0.0",
"rehype-raw": "^7.0.0",
"rehype-recma": "^1.0.0",
"remark-gfm": "^4.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.2",
"remark-stringify": "^11.0.0",
"semver": "^7.8.5",
"unified": "^11.0.5",
"unist-builder": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { loadGenerator } from '@doc-kit/core/generators/loader.mjs';
import { setConfig } from '@doc-kit/core/utils/configuration/index.mjs';
import { loadMarkdownPlugins } from '@doc-kit/core/utils/markdown/plugins.mjs';
import { u } from 'unist-builder';

import { generate } from '../generate.mjs';

const config = await setConfig({ target: ['llms-txt-full'] });

// Pages are serialised with the pipeline of `llms-txt-full`
await loadMarkdownPlugins(
await loadGenerator(import.meta.resolve('../index.mjs'))
);

const entry = (path, text) => ({
path,
content: u('root', [u('paragraph', [u('text', text)])]),
Expand Down
10 changes: 10 additions & 0 deletions packages/react/src/llms-txt-full/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@ export default {
pageURL: llmsTxt.defaultConfiguration.pageURL,
},

markdown: {
// Pages are serialised back to Markdown, type annotations included
remarkPlugins: [
'@doc-kit/core/plugins/type-annotations/remark.mjs',
'remark-gfm',
'remark-stringify',
'...',
],
},

generate,
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { loadGenerator } from '@doc-kit/core/generators/loader.mjs';
import { loadMarkdownPlugins } from '@doc-kit/core/utils/markdown/plugins.mjs';
import { u } from 'unist-builder';

import { buildPages } from '../buildPages.mjs';

// Pages are serialised with the pipeline of `llms-txt-full`
await loadMarkdownPlugins(
await loadGenerator(import.meta.resolve('../../index.mjs'))
);

const entry = (path, text, extra = {}) => ({
path,
content: u('root', [u('paragraph', [u('text', text)])]),
Expand All @@ -25,6 +32,30 @@ describe('buildPages', () => {
]);
});

it('serialises type annotations back to Markdown', () => {
const content = u('root', [
u('paragraph', [
u('text', 'Returns a '),
u('typeAnnotation', { value: 'Promise<string>' }),
u('text', '.'),
]),
]);

assert.deepEqual(buildPages([{ path: '/a', content }]), [
{ path: '/a', markdown: 'Returns a {Promise<string>}.\n' },
]);
});

it('serialises the JSX of MDX pages', () => {
const content = u('root', [
u('mdxJsxFlowElement', { name: 'Foo', attributes: [] }, []),
]);

assert.deepEqual(buildPages([{ path: '/a', content, mdx: true }]), [
{ path: '/a', markdown: '<Foo />\n' },
]);
});

it('leaves out pages generated by other generators', () => {
assert.deepEqual(
buildPages([entry('/all', 'All.', { synthetic: true })]),
Expand Down
8 changes: 5 additions & 3 deletions packages/react/src/llms-txt-full/utils/buildPages.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getRemark, getRemarkMdx } from '@doc-kit/core/utils/remark.mjs';
import { getProcessor } from '@doc-kit/core/utils/markdown/processor.mjs';

/**
* The Markdown of every page, from the content of its entries, in the order
Expand All @@ -18,10 +18,12 @@ export const buildPages = entries => {
}

return [...pages].map(([path, sections]) => {
const remark = sections[0].mdx ? getRemarkMdx() : getRemark();
const processor = getProcessor('llms-txt-full', {
mdx: sections[0].mdx,
});

const markdown = sections
.map(({ content }) => remark.stringify(content).trim())
.map(({ content }) => processor.stringify(content).trim())
.filter(Boolean)
.join('\n\n');

Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading