@rspress/plugin-llms 2.0.0-beta.32 → 2.0.0-beta.34

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 CHANGED
@@ -90,7 +90,7 @@ const mdxToMdPlugin = ()=>(tree)=>{
90
90
  });
91
91
  };
92
92
  function noopPlugin() {}
93
- function normalizeMdFile(content, filepath, routeService, base, mdxToMd, isMd, remarkPlugins) {
93
+ async function normalizeMdFile(content, filepath, routeService, base, mdxToMd, isMd, remarkPlugins) {
94
94
  const compiler = unified().use(remark_parse).use(isMd ? noopPlugin : remark_mdx).use(remarkFileCodeBlock, {
95
95
  filepath
96
96
  }).use(!isMd && mdxToMd ? mdxToMdPlugin : noopPlugin).use(remarkLink, {
@@ -102,10 +102,13 @@ function normalizeMdFile(content, filepath, routeService, base, mdxToMd, isMd, r
102
102
  },
103
103
  __base: base
104
104
  }).use(remarkPlugins).use(remark_stringify);
105
- return compiler.process({
105
+ const vfile = await compiler.process({
106
106
  value: content,
107
107
  path: filepath
108
108
  });
109
+ const result = vfile.toString();
110
+ if ('' === result.trim()) return '\n';
111
+ return result;
109
112
  }
110
113
  const rsbuildPluginLlms = ({ disableSSGRef, baseRef, pageDataList, routes, titleRef, descriptionRef, langRef, sidebar, routeServiceRef, nav, rspressPluginOptions, index = 0 })=>({
111
114
  name: `rsbuild-plugin-llms-${index}`,
@@ -122,7 +125,7 @@ const rsbuildPluginLlms = ({ disableSSGRef, baseRef, pageDataList, routes, title
122
125
  const disableSSG = disableSSGRef.current;
123
126
  const newPageDataList = mergeRouteMetaWithPageData(routes, pageDataList, langRef.current, include, exclude);
124
127
  const navList = Array.isArray(nav) ? nav.map((i)=>{
125
- const nav = i.nav.default;
128
+ const nav = i.nav.default || i.nav;
126
129
  const lang = i.lang;
127
130
  return nav.map((i)=>({
128
131
  ...i,
@@ -165,7 +168,7 @@ const rsbuildPluginLlms = ({ disableSSGRef, baseRef, pageDataList, routes, title
165
168
  const isMD = 'mdx' !== node_path.extname(filepath).slice(1);
166
169
  let mdContent;
167
170
  try {
168
- mdContent = (await normalizeMdFile(content, filepath, routeServiceRef.current, baseRef.current, 'boolean' != typeof mdFiles ? mdFiles?.mdxToMd ?? false : false, isMD, 'boolean' != typeof mdFiles ? mdFiles?.remarkPlugins ?? [] : [])).toString();
171
+ mdContent = await normalizeMdFile(content, filepath, routeServiceRef.current, baseRef.current, 'boolean' != typeof mdFiles ? mdFiles?.mdxToMd ?? false : false, isMD, 'boolean' != typeof mdFiles ? mdFiles?.remarkPlugins ?? [] : []);
169
172
  } catch (e) {
170
173
  logger.debug('normalizeMdFile failed', pageData.routePath, e);
171
174
  mdContent = content;
@@ -7,7 +7,7 @@ var _1 = "llmsContainer-glE3L4";
7
7
  function LlmsContainer(props) {
8
8
  return /*#__PURE__*/ jsx("div", {
9
9
  ...props,
10
- className: _1
10
+ className: `rp-not-doc ${_1}`
11
11
  });
12
12
  }
13
13
  function IconCopy({ className }) {
@@ -78,7 +78,7 @@ function useMdUrl() {
78
78
  const cache = new Map();
79
79
  function LlmsCopyButton(props) {
80
80
  const { onClick, text, textByLang = {
81
- zh: "\u590D\u5236 Markdown",
81
+ zh: '复制 Markdown',
82
82
  en: 'Copy Markdown'
83
83
  }, ...otherProps } = props;
84
84
  const lang = useLang();
@@ -113,6 +113,7 @@ function LlmsCopyButton(props) {
113
113
  ...otherProps,
114
114
  disabled: isLoading,
115
115
  className: [
116
+ 'rp-not-doc',
116
117
  _4,
117
118
  isLoading ? _5 : '',
118
119
  isFinished ? _6 : ''
@@ -199,7 +200,7 @@ const LlmsViewOptions = ({ options = [
199
200
  'claude'
200
201
  ], text, textByLang = {
201
202
  en: 'Open',
202
- zh: "\u6253\u5F00"
203
+ zh: '打开'
203
204
  } })=>{
204
205
  const [isOpen, setIsOpen] = useState(false);
205
206
  const dropdownRef = useRef(null);
@@ -223,7 +224,7 @@ const LlmsViewOptions = ({ options = [
223
224
  const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
224
225
  return {
225
226
  markdownLink: {
226
- title: isEn ? 'Copy Markdown link' : "\u590D\u5236 Markdown \u94FE\u63A5",
227
+ title: isEn ? 'Copy Markdown link' : '复制 Markdown 链接',
227
228
  icon: /*#__PURE__*/ jsx("svg", {
228
229
  xmlns: "http://www.w3.org/2000/svg",
229
230
  viewBox: "0 0 24 24",
@@ -250,7 +251,7 @@ const LlmsViewOptions = ({ options = [
250
251
  }
251
252
  },
252
253
  chatgpt: {
253
- title: isEn ? 'Open in ChatGPT' : "\u5728 ChatGPT \u4E2D\u6253\u5F00",
254
+ title: isEn ? 'Open in ChatGPT' : '在 ChatGPT 中打开',
254
255
  href: `https://chatgpt.com/?${new URLSearchParams({
255
256
  hints: 'search',
256
257
  q
@@ -271,7 +272,7 @@ const LlmsViewOptions = ({ options = [
271
272
  })
272
273
  },
273
274
  claude: {
274
- title: isEn ? 'Open in Claude' : "\u5728 Claude \u4E2D\u6253\u5F00",
275
+ title: isEn ? 'Open in Claude' : '在 Claude 中打开',
275
276
  href: `https://claude.ai/new?${new URLSearchParams({
276
277
  q
277
278
  })}`,
@@ -299,6 +300,7 @@ const LlmsViewOptions = ({ options = [
299
300
  children: /*#__PURE__*/ jsxs("button", {
300
301
  ref: dropdownRef,
301
302
  className: [
303
+ 'rp-not-doc',
302
304
  LlmsViewOptions_module_3,
303
305
  isOpen ? LlmsViewOptions_module_1 : ''
304
306
  ].filter(Boolean).join(' '),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-llms",
3
- "version": "2.0.0-beta.32",
3
+ "version": "2.0.0-beta.34",
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": {
@@ -35,14 +35,14 @@
35
35
  "unist-util-visit": "^5.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@microsoft/api-extractor": "^7.52.11",
39
- "@rsbuild/core": "~1.5.4",
38
+ "@microsoft/api-extractor": "^7.52.13",
39
+ "@rsbuild/core": "~1.5.12",
40
40
  "@rsbuild/plugin-react": "~1.4.0",
41
41
  "@rsbuild/plugin-sass": "~1.4.0",
42
- "@rslib/core": "0.12.4",
42
+ "@rslib/core": "0.13.3",
43
43
  "@types/hast": "^3.0.4",
44
44
  "@types/node": "^22.8.1",
45
- "@types/react": "^19.1.12",
45
+ "@types/react": "^19.1.13",
46
46
  "react": "^19.1.1",
47
47
  "rsbuild-plugin-publint": "^0.3.3",
48
48
  "typescript": "^5.8.2",
@@ -50,7 +50,7 @@
50
50
  "@rspress/config": "1.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@rspress/core": "^2.0.0-beta.32"
53
+ "@rspress/core": "^2.0.0-beta.34"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=18.0.0"