@rspress/plugin-llms 2.0.0-beta.11 → 2.0.0-beta.13
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.
- package/dist/index.js +20 -20
- package/package.json +7 -7
package/dist/index.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import
|
2
|
+
import external_node_path_default from "node:path";
|
3
|
+
import { getSidebarDataGroup, normalizeHref, removeBase } from "@rspress/shared";
|
4
|
+
import { logger } from "@rspress/shared/logger";
|
5
|
+
import { remarkPluginNormalizeLink } from "@rspress/core";
|
6
|
+
import external_remark_mdx_default from "remark-mdx";
|
7
|
+
import external_remark_parse_default from "remark-parse";
|
8
|
+
import external_remark_stringify_default from "remark-stringify";
|
9
|
+
import { unified } from "unified";
|
10
|
+
import { SKIP, visit } from "unist-util-visit";
|
11
11
|
var router_Action;
|
12
12
|
(function(Action) {
|
13
13
|
Action["Pop"] = "POP";
|
@@ -118,7 +118,7 @@ new Set([
|
|
118
118
|
Symbol("deferred");
|
119
119
|
function routePathToMdPath(routePath) {
|
120
120
|
let url = routePath;
|
121
|
-
url =
|
121
|
+
url = normalizeHref(url, false);
|
122
122
|
url = url.replace(/\.html$/, '.md');
|
123
123
|
return url;
|
124
124
|
}
|
@@ -181,19 +181,19 @@ url: ${routePathToMdPath(page.routePath)}
|
|
181
181
|
return lines.join('\n');
|
182
182
|
}
|
183
183
|
const mdxToMdPlugin = ()=>(tree)=>{
|
184
|
-
|
184
|
+
visit(tree, 'mdxjsEsm', (node)=>{
|
185
185
|
if (node.data?.estree?.body[0].type === 'ImportDeclaration') {
|
186
186
|
node.value = '';
|
187
|
-
return
|
187
|
+
return SKIP;
|
188
188
|
}
|
189
189
|
});
|
190
|
-
|
190
|
+
visit(tree, 'mdxJsxFlowElement', (node, index, parent)=>{
|
191
191
|
if (parent && void 0 !== index && Array.isArray(parent.children)) {
|
192
192
|
parent.children.splice(index, 1, ...node.children);
|
193
193
|
return index - 1;
|
194
194
|
}
|
195
195
|
});
|
196
|
-
|
196
|
+
visit(tree, 'mdxJsxTextElement', (node, index, parent)=>{
|
197
197
|
if (parent && void 0 !== index && Array.isArray(parent.children)) {
|
198
198
|
parent.children.splice(index, 1, ...node.children);
|
199
199
|
return index - 1;
|
@@ -201,11 +201,11 @@ const mdxToMdPlugin = ()=>(tree)=>{
|
|
201
201
|
});
|
202
202
|
};
|
203
203
|
function mdxToMd(content, filepath, docDirectory, routeService) {
|
204
|
-
return
|
204
|
+
return unified().use(external_remark_parse_default).use(external_remark_mdx_default).use(mdxToMdPlugin).use(remarkPluginNormalizeLink, {
|
205
205
|
cleanUrls: '.md',
|
206
206
|
root: docDirectory,
|
207
207
|
routeService
|
208
|
-
}).use(
|
208
|
+
}).use(external_remark_stringify_default).process({
|
209
209
|
value: content,
|
210
210
|
path: filepath
|
211
211
|
});
|
@@ -234,7 +234,7 @@ const rsbuildPluginLlms = ({ disableSSGRef, pageDataList, routes, titleRef, desc
|
|
234
234
|
for(let i = 0; i < pageArray.length; i++){
|
235
235
|
const pageArrayItem = pageArray[i];
|
236
236
|
const navItem = navList[i];
|
237
|
-
if (lang === navItem.lang && new RegExp(navItem.activeMatch ?? navItem.link).test(
|
237
|
+
if (lang === navItem.lang && new RegExp(navItem.activeMatch ?? navItem.link).test(removeBase(routePath, base))) return void pageArrayItem.push(pageData);
|
238
238
|
}
|
239
239
|
others.push(pageData);
|
240
240
|
});
|
@@ -259,13 +259,13 @@ const rsbuildPluginLlms = ({ disableSSGRef, pageDataList, routes, titleRef, desc
|
|
259
259
|
].map(async (pageData)=>{
|
260
260
|
const content = pageData._flattenContent ?? pageData.content;
|
261
261
|
const filepath = pageData._filepath;
|
262
|
-
const isMD = 'mdx' !==
|
262
|
+
const isMD = 'mdx' !== external_node_path_default.extname(filepath).slice(1);
|
263
263
|
let mdContent;
|
264
264
|
if (isMD) mdContent = content;
|
265
265
|
else try {
|
266
266
|
mdContent = (await mdxToMd(content, filepath, docDirectory, routeServiceRef.current)).toString();
|
267
267
|
} catch (e) {
|
268
|
-
|
268
|
+
logger.debug(e);
|
269
269
|
mdContent = content;
|
270
270
|
return;
|
271
271
|
}
|
@@ -340,7 +340,7 @@ function flatSidebar(sidebar) {
|
|
340
340
|
function organizeBySidebar(sidebar, pages, base) {
|
341
341
|
if (0 === pages.length) return;
|
342
342
|
const pageItem = pages[0];
|
343
|
-
const currSidebar =
|
343
|
+
const currSidebar = getSidebarDataGroup(sidebar, pageItem.routePath, base);
|
344
344
|
if (0 === currSidebar.length) return;
|
345
345
|
const orderList = flatSidebar(currSidebar);
|
346
346
|
pages.sort((a, b)=>{
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/plugin-llms",
|
3
|
-
"version": "2.0.0-beta.
|
3
|
+
"version": "2.0.0-beta.13",
|
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": {
|
@@ -24,21 +24,21 @@
|
|
24
24
|
"unified": "^11.0.5",
|
25
25
|
"unist-util-visit": "^5.0.0",
|
26
26
|
"unist-util-visit-children": "^3.0.0",
|
27
|
-
"@rspress/shared": "2.0.0-beta.
|
27
|
+
"@rspress/shared": "2.0.0-beta.13"
|
28
28
|
},
|
29
29
|
"devDependencies": {
|
30
30
|
"@microsoft/api-extractor": "^7.52.8",
|
31
|
-
"@rsbuild/core": "~1.3.
|
32
|
-
"@rslib/core": "0.
|
31
|
+
"@rsbuild/core": "~1.3.22",
|
32
|
+
"@rslib/core": "0.9.2",
|
33
33
|
"@types/hast": "^3.0.4",
|
34
34
|
"@types/node": "^22.8.1",
|
35
35
|
"typescript": "^5.8.2",
|
36
36
|
"vfile": "^6.0.3",
|
37
|
-
"@rspress/
|
38
|
-
"@rspress/
|
37
|
+
"@rspress/config": "1.0.0",
|
38
|
+
"@rspress/runtime": "2.0.0-beta.13"
|
39
39
|
},
|
40
40
|
"peerDependencies": {
|
41
|
-
"@rspress/core": "^2.0.0-beta.
|
41
|
+
"@rspress/core": "^2.0.0-beta.13"
|
42
42
|
},
|
43
43
|
"engines": {
|
44
44
|
"node": ">=18.0.0"
|