@rspress/plugin-llms 2.0.0-beta.23 → 2.0.0-beta.24

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
@@ -89,10 +89,11 @@ const mdxToMdPlugin = ()=>(tree)=>{
89
89
  }
90
90
  });
91
91
  };
92
- function mdxToMd(content, filepath, routeService, base) {
93
- return unified().use(remark_parse).use(remark_mdx).use(remarkFileCodeBlock, {
92
+ function noopPlugin() {}
93
+ function normalizeMdFile(content, filepath, routeService, base, mdxToMd, isMd) {
94
+ return unified().use(remark_parse).use(isMd ? noopPlugin : remark_mdx).use(remarkFileCodeBlock, {
94
95
  filepath
95
- }).use(mdxToMdPlugin).use(remarkLink, {
96
+ }).use(!isMd && mdxToMd ? mdxToMdPlugin : noopPlugin).use(remarkLink, {
96
97
  cleanUrls: '.md',
97
98
  routeService,
98
99
  remarkLinkOptions: {
@@ -111,7 +112,7 @@ const rsbuildPluginLlms = ({ disableSSGRef, baseRef, pageDataList, routes, title
111
112
  const { llmsTxt = {
112
113
  name: 'llms.txt'
113
114
  }, mdFiles = {
114
- mdxToMd: true
115
+ mdxToMd: false
115
116
  }, llmsFullTxt = {
116
117
  name: 'llms-full.txt'
117
118
  }, include, exclude } = rspressPluginOptions;
@@ -161,9 +162,8 @@ const rsbuildPluginLlms = ({ disableSSGRef, baseRef, pageDataList, routes, title
161
162
  const filepath = pageData._filepath;
162
163
  const isMD = 'mdx' !== node_path.extname(filepath).slice(1);
163
164
  let mdContent;
164
- if (isMD || mdFiles && false === mdFiles.mdxToMd) mdContent = content;
165
- else try {
166
- mdContent = (await mdxToMd(content, filepath, routeServiceRef.current, baseRef.current)).toString();
165
+ try {
166
+ mdContent = (await normalizeMdFile(content, filepath, routeServiceRef.current, baseRef.current, 'boolean' != typeof mdFiles ? mdFiles?.mdxToMd : false, isMD)).toString();
167
167
  } catch (e) {
168
168
  logger.debug(e);
169
169
  mdContent = content;
@@ -0,0 +1,158 @@
1
+ .llmsContainer-glE3L4 {
2
+ align-items: center;
3
+ gap: 8px;
4
+ margin-bottom: 20px;
5
+ display: flex;
6
+ }
7
+
8
+ .llmsCopyButtonContainer-osHvFn {
9
+ color: #000000e6;
10
+ background: #fff;
11
+ border: 1px solid #e5e6eb;
12
+ border-radius: 8px;
13
+ justify-content: center;
14
+ align-items: center;
15
+ gap: 8px;
16
+ height: 40px;
17
+ padding: 8px 12px;
18
+ font-size: 14px;
19
+ font-style: normal;
20
+ font-weight: 400;
21
+ transition: background .3s, border .3s, opacity .3s;
22
+ display: inline-flex;
23
+ }
24
+
25
+ .llmsCopyButtonContainer-osHvFn:hover {
26
+ background: #f5f5f5;
27
+ border: 1px solid #e5e6eb;
28
+ }
29
+
30
+ .llmsCopyButtonContainer-osHvFn.loading-p5nEhg {
31
+ opacity: .5;
32
+ background: #f5f5f5;
33
+ border: 1px solid #e5e6eb;
34
+ }
35
+
36
+ .llmsCopyButtonContainer-osHvFn.success-F4Qj8u .iconCopy-g1n4MZ {
37
+ display: none;
38
+ }
39
+
40
+ .llmsCopyButtonContainer-osHvFn.success-F4Qj8u .iconSuccess-PId4Mj {
41
+ opacity: 1;
42
+ visibility: inherit;
43
+ transition-delay: 75ms;
44
+ }
45
+
46
+ .iconContainer-G_2NC6 {
47
+ width: 16px;
48
+ height: 16px;
49
+ position: relative;
50
+ }
51
+
52
+ .iconCopy-g1n4MZ {
53
+ width: 16px;
54
+ height: 16px;
55
+ position: absolute;
56
+ top: 50%;
57
+ left: 50%;
58
+ transform: translate(-50%, -50%);
59
+ }
60
+
61
+ .iconSuccess-PId4Mj {
62
+ visibility: hidden;
63
+ opacity: 0;
64
+ width: 16px;
65
+ height: 16px;
66
+ transition: opacity .2s, transform .2s;
67
+ position: absolute;
68
+ top: 50%;
69
+ left: 50%;
70
+ transform: translate(-50%, -50%);
71
+ }
72
+
73
+ .llmsViewOptionsContainer-EuqmUT {
74
+ color: #000000e6;
75
+ background: #fff;
76
+ border: 1px solid #e5e6eb;
77
+ border-radius: 8px;
78
+ justify-content: center;
79
+ align-items: center;
80
+ gap: 8px;
81
+ height: 40px;
82
+ padding: 8px 12px;
83
+ font-size: 14px;
84
+ font-style: normal;
85
+ font-weight: 400;
86
+ line-height: 22px;
87
+ transition: background .3s, border .3s;
88
+ display: inline-flex;
89
+ }
90
+
91
+ .llmsViewOptionsContainer-EuqmUT:hover, .llmsViewOptionsContainer-EuqmUT.active-SacMuO {
92
+ background: #f5f5f5;
93
+ }
94
+
95
+ .dropdownButton-Mj4g7p {
96
+ cursor: pointer;
97
+ position: relative;
98
+ }
99
+
100
+ .dropdownArrow-UjqrjW {
101
+ transition: transform .2s;
102
+ }
103
+
104
+ .dropdownArrow-UjqrjW.rotated-YGs7Vp {
105
+ transform: rotate(180deg);
106
+ }
107
+
108
+ .dropdownMenu-_ggfjT {
109
+ z-index: 2;
110
+ background: #fff;
111
+ border: 1px solid #e5e6eb;
112
+ border-radius: 8px;
113
+ flex-direction: column;
114
+ align-items: flex-start;
115
+ width: 250px;
116
+ margin-top: 4px;
117
+ padding: 8px;
118
+ display: inline-flex;
119
+ position: absolute;
120
+ top: 100%;
121
+ left: -10%;
122
+ box-shadow: 0 4px 16px #0000000a;
123
+ }
124
+
125
+ .dropdownItem-taWikf {
126
+ text-align: left;
127
+ cursor: pointer;
128
+ background: none;
129
+ border: none;
130
+ border-radius: 8px;
131
+ align-items: center;
132
+ gap: 8px;
133
+ width: 100%;
134
+ padding: 8px 12px;
135
+ font-size: 14px;
136
+ display: flex;
137
+ }
138
+
139
+ .dropdownItem-taWikf:hover {
140
+ background: #f5f5f5;
141
+ }
142
+
143
+ .githubIcon-lJkbbr {
144
+ justify-content: center;
145
+ align-items: center;
146
+ width: 16px;
147
+ height: 16px;
148
+ font-size: 16px;
149
+ display: inline-flex;
150
+ }
151
+
152
+ .externalIcon-r8tMpa {
153
+ width: 16px;
154
+ height: 16px;
155
+ margin-left: auto;
156
+ font-size: 16px;
157
+ }
158
+
@@ -0,0 +1,60 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import type { default as React_2 } from 'react';
3
+
4
+ export declare function LlmsContainer(props: LlmsContainerProps): JSX.Element;
5
+
6
+ export declare interface LlmsContainerProps extends React_2.HTMLAttributes<HTMLDivElement> {
7
+ }
8
+
9
+ export declare function LlmsCopyButton(props: LlmsCopyButtonProps): JSX.Element;
10
+
11
+ export declare interface LlmsCopyButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
12
+ /**
13
+ * Text by language, used with `useLang`.
14
+ * @default en: 'Copy Markdown', zh: '复制 Markdown'
15
+ */
16
+ textByLang?: Record<string, string>;
17
+ /**
18
+ * Priority is higher than textByLang
19
+ * @default ''
20
+ */
21
+ text?: string;
22
+ /**
23
+ * Overrides the default click handler.
24
+ * If provided, the default copy to clipboard functionality will not be executed.
25
+ */
26
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
27
+ }
28
+
29
+ export declare const LlmsViewOptions: ({ options, text, textByLang, }: LlmsViewOptionsProps) => JSX.Element;
30
+
31
+ export declare interface LlmsViewOptionsProps extends React_2.ButtonHTMLAttributes<HTMLButtonElement> {
32
+ /**
33
+ * Default options for the dropdown.
34
+ * @default ['chatgpt', 'claude']
35
+ * - 'chatgpt': Open in ChatGPT
36
+ * - 'claude': Open in Claude
37
+ */
38
+ options?: Array<{
39
+ title: string;
40
+ href: string;
41
+ icon: React_2.ReactNode;
42
+ } | 'claude' | 'chatgpt'>;
43
+ /**
44
+ * Button text by language, used with `useLang`.
45
+ * @default en: 'Open', zh: '打开'
46
+ */
47
+ textByLang?: Record<string, string>;
48
+ /**
49
+ * Button text.
50
+ * Priority is higher than textByLang
51
+ * @default ''
52
+ */
53
+ text?: string;
54
+ }
55
+
56
+ export declare function useMdUrl(): {
57
+ pathname: string;
58
+ };
59
+
60
+ export { }
@@ -0,0 +1,313 @@
1
+ import "./index.css"
2
+ /*! For license information please see index.js.LICENSE.txt */
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { normalizeHref, useLang, usePageData, withBase } from "@rspress/core/runtime";
5
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
+ var _1 = "llmsContainer-glE3L4";
7
+ function LlmsContainer(props) {
8
+ return /*#__PURE__*/ jsx("div", {
9
+ ...props,
10
+ className: _1
11
+ });
12
+ }
13
+ var LlmsCopyButton_module_1 = "iconContainer-G_2NC6";
14
+ var _2 = "iconCopy-g1n4MZ";
15
+ var _3 = "iconSuccess-PId4Mj";
16
+ var _4 = "llmsCopyButtonContainer-osHvFn";
17
+ var _5 = "loading-p5nEhg";
18
+ var _6 = "success-F4Qj8u";
19
+ function routePathToMdPath(routePath) {
20
+ let url = routePath;
21
+ url = normalizeHref(url, false);
22
+ url = url.replace(/\.html$/, '.md');
23
+ return withBase(url);
24
+ }
25
+ function useMdUrl() {
26
+ const { page } = usePageData();
27
+ const mdPath = useMemo(()=>{
28
+ const pathname = routePathToMdPath(page.routePath);
29
+ return {
30
+ pathname
31
+ };
32
+ }, [
33
+ page.routePath
34
+ ]);
35
+ return mdPath;
36
+ }
37
+ /**
38
+ * Inspired from fumadocs docsite
39
+ * @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
40
+ * @license MIT
41
+ */ function IconCopy() {
42
+ return /*#__PURE__*/ jsxs("svg", {
43
+ xmlns: "http://www.w3.org/2000/svg",
44
+ width: "16",
45
+ height: "16",
46
+ viewBox: "0 0 16 16",
47
+ className: _2,
48
+ fill: "none",
49
+ children: [
50
+ /*#__PURE__*/ jsx("path", {
51
+ d: "M4.33301 4.14386V2.60416C4.33301 2.08639 4.75274 1.66666 5.27051 1.66666H13.3955C13.9133 1.66666 14.333 2.08639 14.333 2.60416V10.7292C14.333 11.2469 13.9133 11.6667 13.3955 11.6667H11.8384",
52
+ stroke: "#808080",
53
+ strokeWidth: "1.33333",
54
+ strokeLinecap: "round",
55
+ strokeLinejoin: "round"
56
+ }),
57
+ /*#__PURE__*/ jsx("path", {
58
+ d: "M10.7295 4.33334H2.60449C2.08673 4.33334 1.66699 4.75308 1.66699 5.27084V13.3958C1.66699 13.9136 2.08673 14.3333 2.60449 14.3333H10.7295C11.2473 14.3333 11.667 13.9136 11.667 13.3958V5.27084C11.667 4.75308 11.2473 4.33334 10.7295 4.33334Z",
59
+ stroke: "#808080",
60
+ strokeWidth: "1.33333",
61
+ strokeLinejoin: "round"
62
+ })
63
+ ]
64
+ });
65
+ }
66
+ function IconSuccess() {
67
+ return /*#__PURE__*/ jsx("svg", {
68
+ width: "32",
69
+ height: "32",
70
+ viewBox: "0 0 30 30",
71
+ className: _3,
72
+ children: /*#__PURE__*/ jsx("path", {
73
+ fill: "#49cd37",
74
+ d: "m13 24l-9-9l1.414-1.414L13 21.171L26.586 7.586L28 9L13 24z"
75
+ })
76
+ });
77
+ }
78
+ const cache = new Map();
79
+ function LlmsCopyButton(props) {
80
+ const { onClick, text, textByLang = {
81
+ zh: "\u590D\u5236 Markdown",
82
+ en: 'Copy Markdown'
83
+ }, ...otherProps } = props;
84
+ const lang = useLang();
85
+ const { pathname } = useMdUrl();
86
+ const [isLoading, setLoading] = useState(false);
87
+ const [isFinished, setFinished] = useState(false);
88
+ const timer = useRef(null);
89
+ const handleClick = useCallback(async ()=>{
90
+ setLoading(true);
91
+ const url = pathname;
92
+ try {
93
+ const content = cache.get(url) ?? await fetch(url).then((res)=>res.text());
94
+ cache.set(url, content);
95
+ await navigator.clipboard.writeText(content);
96
+ } finally{
97
+ setLoading(false);
98
+ setFinished(true);
99
+ if (timer.current) {
100
+ clearTimeout(timer.current);
101
+ timer.current = null;
102
+ }
103
+ timer.current = window.setTimeout(()=>{
104
+ setFinished(false);
105
+ timer.current = null;
106
+ }, 500);
107
+ }
108
+ }, [
109
+ pathname
110
+ ]);
111
+ if (!pathname) return /*#__PURE__*/ jsx(Fragment, {});
112
+ return /*#__PURE__*/ jsxs("button", {
113
+ ...otherProps,
114
+ disabled: isLoading,
115
+ className: [
116
+ _4,
117
+ isLoading ? _5 : '',
118
+ isFinished ? _6 : ''
119
+ ].filter(Boolean).join(' '),
120
+ onClick: onClick ?? handleClick,
121
+ children: [
122
+ /*#__PURE__*/ jsxs("div", {
123
+ className: LlmsCopyButton_module_1,
124
+ children: [
125
+ /*#__PURE__*/ jsx(IconSuccess, {}),
126
+ /*#__PURE__*/ jsx(IconCopy, {})
127
+ ]
128
+ }),
129
+ /*#__PURE__*/ jsx("span", {
130
+ children: text ?? textByLang?.[lang] ?? 'Copy Markdown'
131
+ })
132
+ ]
133
+ });
134
+ }
135
+ var LlmsViewOptions_module_1 = "active-SacMuO";
136
+ var LlmsViewOptions_module_2 = "dropdownArrow-UjqrjW";
137
+ var LlmsViewOptions_module_3 = "dropdownButton-Mj4g7p";
138
+ var LlmsViewOptions_module_4 = "dropdownItem-taWikf";
139
+ var LlmsViewOptions_module_5 = "dropdownMenu-_ggfjT";
140
+ var LlmsViewOptions_module_6 = "externalIcon-r8tMpa";
141
+ var _7 = "githubIcon-lJkbbr";
142
+ var _8 = "llmsViewOptionsContainer-EuqmUT";
143
+ var _9 = "rotated-YGs7Vp";
144
+ /**
145
+ * Inspired from fumadocs docsite
146
+ * @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
147
+ * @license MIT
148
+ */ const IconArrow = ({ className })=>/*#__PURE__*/ jsx("svg", {
149
+ className: className,
150
+ xmlns: "http://www.w3.org/2000/svg",
151
+ width: "16",
152
+ height: "16",
153
+ viewBox: "0 0 15 16",
154
+ fill: "none",
155
+ children: /*#__PURE__*/ jsx("path", {
156
+ d: "M11.125 5.27885L7 9.72115L2.875 5.27885",
157
+ stroke: "#4E5969",
158
+ strokeWidth: "1.125",
159
+ strokeLinecap: "round",
160
+ strokeLinejoin: "round"
161
+ })
162
+ });
163
+ const IconExternalLink = ()=>/*#__PURE__*/ jsxs("svg", {
164
+ xmlns: "http://www.w3.org/2000/svg",
165
+ width: "16",
166
+ height: "16",
167
+ viewBox: "0 0 16 16",
168
+ fill: "none",
169
+ children: [
170
+ /*#__PURE__*/ jsx("path", {
171
+ d: "M9.33301 2H13.9997V6.66667",
172
+ stroke: "#808080",
173
+ strokeWidth: "1.33333",
174
+ strokeLinecap: "round",
175
+ strokeLinejoin: "round"
176
+ }),
177
+ /*#__PURE__*/ jsx("path", {
178
+ d: "M14 9.82457V13C14 13.5523 13.5523 14 13 14H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2H6",
179
+ stroke: "#808080",
180
+ strokeWidth: "1.33333",
181
+ strokeLinecap: "round",
182
+ strokeLinejoin: "round"
183
+ }),
184
+ /*#__PURE__*/ jsx("path", {
185
+ d: "M8.59961 7.39996L13.6996 2.29996",
186
+ stroke: "#808080",
187
+ strokeWidth: "1.33333",
188
+ strokeLinecap: "round",
189
+ strokeLinejoin: "round"
190
+ })
191
+ ]
192
+ });
193
+ const LlmsViewOptions = ({ options = [
194
+ 'chatgpt',
195
+ 'claude'
196
+ ], text, textByLang = {
197
+ en: 'Open',
198
+ zh: "\u6253\u5F00"
199
+ } })=>{
200
+ const [isOpen, setIsOpen] = useState(false);
201
+ const dropdownRef = useRef(null);
202
+ useEffect(()=>{
203
+ const handleClickOutside = (event)=>{
204
+ if (dropdownRef.current && event.target && !dropdownRef.current.contains(event.target)) setIsOpen(false);
205
+ };
206
+ document.addEventListener('mousedown', handleClickOutside);
207
+ return ()=>{
208
+ document.removeEventListener('mousedown', handleClickOutside);
209
+ };
210
+ }, []);
211
+ const toggleDropdown = ()=>{
212
+ setIsOpen(!isOpen);
213
+ };
214
+ const { pathname } = useMdUrl();
215
+ const lang = useLang();
216
+ const isEn = !lang || 'en' === lang;
217
+ const items = useMemo(()=>{
218
+ const fullMarkdownUrl = 'undefined' != typeof window ? new URL(pathname, window.location.origin) : 'loading';
219
+ const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
220
+ return {
221
+ chatgpt: {
222
+ title: isEn ? 'Open in ChatGPT' : "\u5728 ChatGPT \u4E2D\u6253\u5F00",
223
+ href: `https://chatgpt.com/?${new URLSearchParams({
224
+ hints: 'search',
225
+ q
226
+ })}`,
227
+ icon: /*#__PURE__*/ jsxs("svg", {
228
+ role: "img",
229
+ viewBox: "0 0 24 24",
230
+ fill: "currentColor",
231
+ xmlns: "http://www.w3.org/2000/svg",
232
+ children: [
233
+ /*#__PURE__*/ jsx("title", {
234
+ children: "OpenAI"
235
+ }),
236
+ /*#__PURE__*/ jsx("path", {
237
+ d: "M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"
238
+ })
239
+ ]
240
+ })
241
+ },
242
+ claude: {
243
+ title: isEn ? 'Open in Claude' : "\u5728 Claude \u4E2D\u6253\u5F00",
244
+ href: `https://claude.ai/new?${new URLSearchParams({
245
+ q
246
+ })}`,
247
+ icon: /*#__PURE__*/ jsxs("svg", {
248
+ fill: "currentColor",
249
+ role: "img",
250
+ viewBox: "0 0 24 24",
251
+ xmlns: "http://www.w3.org/2000/svg",
252
+ children: [
253
+ /*#__PURE__*/ jsx("title", {
254
+ children: "Anthropic"
255
+ }),
256
+ /*#__PURE__*/ jsx("path", {
257
+ d: "M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"
258
+ })
259
+ ]
260
+ })
261
+ }
262
+ };
263
+ }, [
264
+ pathname,
265
+ isEn
266
+ ]);
267
+ return /*#__PURE__*/ jsx(Fragment, {
268
+ children: /*#__PURE__*/ jsxs("button", {
269
+ ref: dropdownRef,
270
+ className: [
271
+ LlmsViewOptions_module_3,
272
+ _8,
273
+ isOpen ? LlmsViewOptions_module_1 : ''
274
+ ].filter(Boolean).join(' '),
275
+ type: "button",
276
+ onClick: toggleDropdown,
277
+ children: [
278
+ text ?? textByLang[lang] ?? 'Open',
279
+ /*#__PURE__*/ jsx(IconArrow, {
280
+ className: `${LlmsViewOptions_module_2} ${isOpen ? _9 : ''}`
281
+ }),
282
+ isOpen && /*#__PURE__*/ jsx("div", {
283
+ className: LlmsViewOptions_module_5,
284
+ children: options.map((item)=>{
285
+ let displayItem = item;
286
+ if ('chatgpt' === item) displayItem = items.chatgpt;
287
+ else if ('claude' === item) displayItem = items.claude;
288
+ return /*#__PURE__*/ jsxs("a", {
289
+ className: LlmsViewOptions_module_4,
290
+ href: displayItem.href,
291
+ target: "_blank",
292
+ rel: "noopener noreferrer",
293
+ children: [
294
+ /*#__PURE__*/ jsx("span", {
295
+ className: _7,
296
+ children: displayItem.icon
297
+ }),
298
+ /*#__PURE__*/ jsx("span", {
299
+ children: displayItem.title
300
+ }),
301
+ /*#__PURE__*/ jsx("span", {
302
+ className: LlmsViewOptions_module_6,
303
+ children: /*#__PURE__*/ jsx(IconExternalLink, {})
304
+ })
305
+ ]
306
+ }, displayItem.title);
307
+ })
308
+ })
309
+ ]
310
+ })
311
+ });
312
+ };
313
+ export { LlmsContainer, LlmsCopyButton, LlmsViewOptions, useMdUrl };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Inspired from fumadocs docsite
3
+ * @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
4
+ * @license MIT
5
+ */
package/package.json CHANGED
@@ -1,15 +1,25 @@
1
1
  {
2
2
  "name": "@rspress/plugin-llms",
3
- "version": "2.0.0-beta.23",
3
+ "version": "2.0.0-beta.24",
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": {
7
7
  "type": "git",
8
- "url": "https://github.com/web-infra-dev/rspress",
8
+ "url": "git+https://github.com/web-infra-dev/rspress.git",
9
9
  "directory": "packages/plugin-llm"
10
10
  },
11
11
  "license": "MIT",
12
12
  "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./runtime": {
19
+ "types": "./dist/runtime/index.d.ts",
20
+ "default": "./dist/runtime/index.js"
21
+ }
22
+ },
13
23
  "main": "./dist/index.js",
14
24
  "module": "./dist/index.js",
15
25
  "types": "./dist/index.d.ts",
@@ -27,16 +37,21 @@
27
37
  },
28
38
  "devDependencies": {
29
39
  "@microsoft/api-extractor": "^7.52.9",
30
- "@rsbuild/core": "~1.4.11",
40
+ "@rsbuild/core": "~1.4.12",
41
+ "@rsbuild/plugin-react": "~1.3.4",
42
+ "@rsbuild/plugin-sass": "~1.3.3",
31
43
  "@rslib/core": "0.11.0",
32
44
  "@types/hast": "^3.0.4",
33
45
  "@types/node": "^22.8.1",
46
+ "@types/react": "^19.1.8",
47
+ "react": "^19.1.0",
48
+ "rsbuild-plugin-publint": "^0.3.2",
34
49
  "typescript": "^5.8.2",
35
50
  "vfile": "^6.0.3",
36
51
  "@rspress/config": "1.0.0"
37
52
  },
38
53
  "peerDependencies": {
39
- "@rspress/core": "^2.0.0-beta.23"
54
+ "@rspress/core": "^2.0.0-beta.24"
40
55
  },
41
56
  "engines": {
42
57
  "node": ">=18.0.0"