@rspress/plugin-llms 2.0.9 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +8 -4
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -92,9 +92,10 @@ const mdxToMdPlugin = ()=>(tree)=>{
92
92
  });
93
93
  };
94
94
  function noopPlugin() {}
95
- async function normalizeMdFile(content, filepath, routeService, base, mdxToMd, isMd, remarkPlugins) {
95
+ async function normalizeMdFile(docDirectory, content, filepath, routeService, base, mdxToMd, isMd, remarkPlugins) {
96
96
  const compiler = unified().use(remark_parse).use(isMd ? noopPlugin : remark_mdx).use(remarkFileCodeBlock, {
97
- filepath
97
+ filepath,
98
+ docDirectory
98
99
  }).use(!isMd && mdxToMd ? mdxToMdPlugin : noopPlugin).use(remarkLink, {
99
100
  cleanUrls: '.md',
100
101
  routeService,
@@ -126,7 +127,7 @@ function resolveNavForVersion(nav, version, defaultVersion) {
126
127
  }));
127
128
  }).filter((i)=>i.activeMatch || i.link);
128
129
  }
129
- const rsbuildPluginLlms = ({ disableSSGRef, baseRef, pageDataList, routes, titleRef, descriptionRef, langRef, sidebar, routeServiceRef, nav, versionsRef, defaultVersionRef, rspressPluginOptions, index = 0 })=>({
130
+ const rsbuildPluginLlms = ({ docDirectory, disableSSGRef, baseRef, pageDataList, routes, titleRef, descriptionRef, langRef, sidebar, routeServiceRef, nav, versionsRef, defaultVersionRef, rspressPluginOptions, index = 0 })=>({
130
131
  name: `rsbuild-plugin-llms-${index}`,
131
132
  async setup (api) {
132
133
  const { llmsTxt = {
@@ -152,7 +153,7 @@ const rsbuildPluginLlms = ({ disableSSGRef, baseRef, pageDataList, routes, title
152
153
  const isMD = 'mdx' !== node_path.extname(filepath).slice(1);
153
154
  let mdContent;
154
155
  try {
155
- mdContent = await normalizeMdFile(content, filepath, routeServiceRef.current, baseRef.current, 'boolean' != typeof mdFiles ? mdFiles?.mdxToMd ?? false : false, isMD, 'boolean' != typeof mdFiles ? mdFiles?.remarkPlugins ?? [] : []);
156
+ mdContent = await normalizeMdFile(docDirectory, content, filepath, routeServiceRef.current, baseRef.current, 'boolean' != typeof mdFiles ? mdFiles?.mdxToMd ?? false : false, isMD, 'boolean' != typeof mdFiles ? mdFiles?.remarkPlugins ?? [] : []);
156
157
  } catch (e) {
157
158
  logger.debug('normalizeMdFile failed', pageData.routePath, e);
158
159
  mdContent = content;
@@ -352,7 +353,9 @@ function pluginLlms(options) {
352
353
  mergedOptions = void 0 === options ? getDefaultOptions(config.lang, langs) : options;
353
354
  if (!config.builderConfig) config.builderConfig = {};
354
355
  if (!config.builderConfig.plugins) config.builderConfig.plugins = [];
356
+ const docDirectory = config.root;
355
357
  config.builderConfig.plugins.push(...Array.isArray(mergedOptions) ? mergedOptions.map((item, index)=>rsbuildPluginLlms({
358
+ docDirectory,
356
359
  pageDataList,
357
360
  routes,
358
361
  titleRef,
@@ -369,6 +372,7 @@ function pluginLlms(options) {
369
372
  index
370
373
  })) : [
371
374
  rsbuildPluginLlms({
375
+ docDirectory,
372
376
  pageDataList,
373
377
  routes,
374
378
  titleRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-llms",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "A plugin for rspress to generate llms.txt, llms-full.txt, md files to let llm understand your website.",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -36,20 +36,20 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@microsoft/api-extractor": "^7.57.7",
39
- "@rsbuild/core": "2.0.0-rc.1",
40
- "@rsbuild/plugin-react": "~1.4.6",
41
- "@rslib/core": "0.21.0",
39
+ "@rsbuild/core": "^2.0.5",
40
+ "@rsbuild/plugin-react": "~2.0.0",
41
+ "@rslib/core": "0.21.4",
42
42
  "@types/hast": "^3.0.4",
43
43
  "@types/node": "^22.8.1",
44
44
  "@types/react": "^19.2.14",
45
- "react": "^19.2.4",
45
+ "react": "^19.2.6",
46
46
  "rsbuild-plugin-publint": "^0.3.4",
47
47
  "typescript": "^5.8.2",
48
48
  "vfile": "^6.0.3",
49
49
  "@rspress/config": "1.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@rspress/core": "^2.0.9"
52
+ "@rspress/core": "^2.0.10"
53
53
  },
54
54
  "engines": {
55
55
  "node": "^20.19.0 || >=22.12.0"