@rspress/plugin-llms 2.0.0-beta.2 → 2.0.0-beta.4

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.d.ts CHANGED
@@ -1,232 +1,5 @@
1
- import type { PluggableList } from 'unified';
2
- import { RsbuildConfig } from './types';
3
- import { RsbuildPlugin } from './types';
4
-
5
- /**
6
- * There are two ways to define what addition routes represent.
7
- * 1. Define filepath, then the content will be read from the file.
8
- * 2. Define content, then then content will be written to temp file and read from it.
9
- */
10
- declare interface AdditionalPage {
11
- routePath: string;
12
- content?: string;
13
- filepath?: string;
14
- }
15
-
16
- declare interface DefaultThemeConfig {
17
- /**
18
- * Whether to enable dark mode.
19
- * @default true
20
- */
21
- darkMode?: boolean;
22
- /**
23
- * Custom outline title in the aside component.
24
- *
25
- * @default 'ON THIS PAGE'
26
- */
27
- outlineTitle?: string;
28
- /**
29
- * Whether to show the sidebar in right position.
30
- */
31
- outline?: boolean;
32
- /**
33
- * The nav items. When it's an object, the key is the version of current doc.
34
- */
35
- nav?: NavItem[] | {
36
- [key: string]: NavItem[];
37
- };
38
- /**
39
- * The sidebar items.
40
- */
41
- sidebar?: Sidebar;
42
- /**
43
- * Info for the edit link. If it's undefined, the edit link feature will
44
- * be disabled.
45
- */
46
- editLink?: EditLink;
47
- /**
48
- * Set custom last updated text.
49
- *
50
- * @default 'Last updated'
51
- */
52
- lastUpdatedText?: string;
53
- /**
54
- * Set custom last updated text.
55
- *
56
- * @default false
57
- */
58
- lastUpdated?: boolean;
59
- /**
60
- * Set custom prev/next labels.
61
- */
62
- docFooter?: DocFooter;
63
- /**
64
- * The social links to be displayed at the end of the nav bar. Perfect for
65
- * placing links to social services such as GitHub, X, Facebook, etc.
66
- */
67
- socialLinks?: SocialLink[];
68
- /**
69
- * The footer configuration.
70
- */
71
- footer?: Footer;
72
- /**
73
- * The prev page text.
74
- */
75
- prevPageText?: string;
76
- /**
77
- * The next page text.
78
- */
79
- nextPageText?: string;
80
- /**
81
- * The source code text.
82
- */
83
- sourceCodeText?: string;
84
- /**
85
- * Locale config
86
- */
87
- locales?: LocaleConfig[];
88
- /**
89
- * Whether to open the full text search
90
- */
91
- search?: boolean;
92
- /**
93
- * The placeholder of search input
94
- */
95
- searchPlaceholderText?: string;
96
- /**
97
- * The text of no search result
98
- */
99
- searchNoResultsText?: string;
100
- /**
101
- * The text of suggested query text when no search result
102
- */
103
- searchSuggestedQueryText?: string;
104
- /**
105
- * The text of overview filter
106
- */
107
- overview?: FilterConfig;
108
- /**
109
- * The behavior of hiding navbar
110
- */
111
- hideNavbar?: 'always' | 'auto' | 'never';
112
- /**
113
- * Whether to enable view transition animation for pages switching
114
- */
115
- enableContentAnimation?: boolean;
116
- /**
117
- * Whether to enable view transition animation for the theme
118
- */
119
- enableAppearanceAnimation?: boolean;
120
- /**
121
- * Enable scroll to top button on documentation
122
- * @default false
123
- */
124
- enableScrollToTop?: boolean;
125
- /**
126
- * Whether to redirect to the closest locale when the user visits the site
127
- * @default 'auto'
128
- */
129
- localeRedirect?: 'auto' | 'never';
130
- /**
131
- * Whether to show the fallback heading title when the heading title is not presented but `frontmatter.title` exists
132
- * @default true
133
- */
134
- fallbackHeadingTitle?: boolean;
135
- }
136
-
137
- declare interface DocFooter {
138
- /**
139
- * Custom label for previous page button.
140
- */
141
- prev?: SidebarItem;
142
- /**
143
- * Custom label for next page button.
144
- */
145
- next?: SidebarItem;
146
- }
147
-
148
- declare interface EditLink {
149
- /**
150
- * Custom repository url for edit link.
151
- */
152
- docRepoBaseUrl: string;
153
- /**
154
- * Custom text for edit link.
155
- *
156
- * @default 'Edit this page'
157
- */
158
- text?: string;
159
- }
160
-
161
- declare interface Feature {
162
- icon: string;
163
- title: string;
164
- details: string;
165
- span?: number;
166
- link?: string;
167
- }
168
-
169
- /**
170
- * The config of filter component
171
- */
172
- declare interface FilterConfig {
173
- filterNameText?: string;
174
- filterPlaceholderText?: string;
175
- filterNoResultText?: string;
176
- }
177
-
178
- declare interface Footer {
179
- message?: string;
180
- }
181
-
182
- declare interface FrontMatterMeta {
183
- title?: string;
184
- description?: string;
185
- overview?: boolean;
186
- pageType?: PageType;
187
- features?: Feature[];
188
- hero?: Hero;
189
- sidebar?: boolean;
190
- outline?: boolean;
191
- lineNumbers?: boolean;
192
- overviewHeaders?: number[];
193
- titleSuffix?: string;
194
- head?: [string, Record<string, string>][];
195
- context?: string;
196
- footer?: boolean;
197
- [key: string]: unknown;
198
- }
199
-
200
- declare interface Header {
201
- id: string;
202
- text: string;
203
- depth: number;
204
- charIndex: number;
205
- }
206
-
207
- declare interface Hero {
208
- name: string;
209
- text: string;
210
- tagline: string;
211
- image?: {
212
- src: string | {
213
- dark: string;
214
- light: string;
215
- };
216
- alt: string;
217
- /**
218
- * `srcset` and `sizes` are attributes of `<img>` tag. Please refer to https://mdn.io/srcset for the usage.
219
- * When the value is an array, rspress will join array members with commas.
220
- **/
221
- sizes?: string | string[];
222
- srcset?: string | string[];
223
- };
224
- actions: {
225
- text: string;
226
- link: string;
227
- theme: 'brand' | 'alt';
228
- }[];
229
- }
1
+ import type { PageIndexInfo } from '@rspress/shared';
2
+ import type { RspressPlugin } from '@rspress/shared';
230
3
 
231
4
  export declare interface LlmsTxt {
232
5
  onTitleGenerate?: (context: {
@@ -237,112 +10,6 @@ export declare interface LlmsTxt {
237
10
  onAfterLlmsTxtGenerate?: (llmsTxtContent: string) => string;
238
11
  }
239
12
 
240
- declare interface Locale {
241
- lang: string;
242
- label: string;
243
- title?: string;
244
- description?: string;
245
- }
246
-
247
- /**
248
- * locale config
249
- */
250
- declare interface LocaleConfig {
251
- /**
252
- * Site i18n config, which will recover the locales config in the site level.
253
- */
254
- lang: string;
255
- title?: string;
256
- description?: string;
257
- label: string;
258
- /**
259
- * Theme i18n config
260
- */
261
- nav?: Nav;
262
- sidebar?: Sidebar;
263
- outlineTitle?: string;
264
- lastUpdatedText?: string;
265
- lastUpdated?: boolean;
266
- editLink?: EditLink;
267
- prevPageText?: string;
268
- nextPageText?: string;
269
- sourceCodeText?: string;
270
- langRoutePrefix?: string;
271
- searchPlaceholderText?: string;
272
- searchNoResultsText?: string;
273
- searchSuggestedQueryText?: string;
274
- overview?: FilterConfig;
275
- }
276
-
277
- declare type LocalSearchOptions = SearchHooks & {
278
- mode?: 'local';
279
- /**
280
- * Whether to generate separate search index for each version
281
- */
282
- versioned?: boolean;
283
- /**
284
- * If enabled, the search index will include code block content, which allows users to search code blocks.
285
- * @default false
286
- */
287
- codeBlocks?: boolean;
288
- };
289
-
290
- declare interface MarkdownOptions {
291
- remarkPlugins?: PluggableList;
292
- rehypePlugins?: PluggableList;
293
- /**
294
- * Whether to enable check dead links, default is false
295
- */
296
- checkDeadLinks?: boolean;
297
- showLineNumbers?: boolean;
298
- /**
299
- * Whether to wrap code by default, default is false
300
- */
301
- defaultWrapCode?: boolean;
302
- /**
303
- * Register global components in mdx files
304
- */
305
- globalComponents?: string[];
306
- /**
307
- * Code highlighter, default is prism for performance reason
308
- */
309
- codeHighlighter?: 'prism' | 'shiki';
310
- /**
311
- * Register prism languages
312
- */
313
- highlightLanguages?: (string | [string, string])[];
314
- }
315
-
316
- declare type Nav = NavItem[] | {
317
- [key: string]: NavItem[];
318
- };
319
-
320
- declare type NavItem = NavItemWithLink | NavItemWithChildren | NavItemWithLinkAndChildren;
321
-
322
- declare interface NavItemWithChildren {
323
- text?: string;
324
- tag?: string;
325
- items: NavItemWithLink[];
326
- position?: 'left' | 'right';
327
- }
328
-
329
- declare type NavItemWithLink = {
330
- text: string;
331
- link: string;
332
- tag?: string;
333
- activeMatch?: string;
334
- position?: 'left' | 'right';
335
- };
336
-
337
- declare interface NavItemWithLinkAndChildren {
338
- text: string;
339
- link: string;
340
- items: NavItemWithLink[];
341
- tag?: string;
342
- activeMatch?: string;
343
- position?: 'left' | 'right';
344
- }
345
-
346
13
  export declare interface Options {
347
14
  /**
348
15
  * Whether to generate llms.txt.
@@ -377,404 +44,9 @@ export declare interface Options {
377
44
  }) => boolean;
378
45
  }
379
46
 
380
- /**
381
- * @description search-index.json file
382
- * "_foo" is the private field that won't be written to search-index.json file
383
- * and should not be used in the runtime (usePageData).
384
- */
385
- declare interface PageIndexInfo {
386
- id: number;
387
- title: string;
388
- routePath: string;
389
- toc: Header[];
390
- content: string;
391
- _flattenContent?: string;
392
- _html: string;
393
- frontmatter: FrontMatterMeta;
394
- lang: string;
395
- version: string;
396
- domain: string;
397
- _filepath: string;
398
- _relativePath: string;
399
- }
400
-
401
- declare type PageType = 'home' | 'doc' | 'custom' | '404' | 'blank';
402
-
403
47
  /**
404
48
  * A plugin for rspress to generate llms.txt, llms-full.txt, md files to let llm understand your website.
405
49
  */
406
50
  export declare function pluginLlms(options?: Options): RspressPlugin;
407
51
 
408
- declare type RemoteSearchIndexInfo = string | {
409
- value: string;
410
- label: string;
411
- };
412
-
413
- declare type RemoteSearchOptions = SearchHooks & {
414
- mode: 'remote';
415
- apiUrl: string;
416
- domain?: string;
417
- indexName: string;
418
- searchIndexes?: RemoteSearchIndexInfo[];
419
- searchLoading?: boolean;
420
- };
421
-
422
- declare interface ReplaceRule {
423
- search: string | RegExp;
424
- replace: string;
425
- }
426
-
427
- declare interface RouteMeta {
428
- routePath: string;
429
- absolutePath: string;
430
- relativePath: string;
431
- pageName: string;
432
- lang: string;
433
- version: string;
434
- }
435
-
436
- declare interface RouteOptions {
437
- /**
438
- * The extension name of the filepath that will be converted to a route
439
- * @default ['js','jsx','ts','tsx','md','mdx']
440
- */
441
- extensions?: string[];
442
- /**
443
- * Include extra files from being converted to routes
444
- */
445
- include?: string[];
446
- /**
447
- * Exclude files from being converted to routes
448
- */
449
- exclude?: string[];
450
- /**
451
- * use links without .html files
452
- */
453
- cleanUrls?: boolean;
454
- }
455
-
456
- declare interface RspressPlugin {
457
- /**
458
- * Name of the plugin.
459
- */
460
- name: string;
461
- /**
462
- * Global style
463
- */
464
- globalStyles?: string;
465
- /**
466
- * Markdown options.
467
- */
468
- markdown?: {
469
- remarkPlugins?: PluggableList;
470
- rehypePlugins?: PluggableList;
471
- globalComponents?: string[];
472
- };
473
- /**
474
- * Rsbuild config.
475
- */
476
- builderConfig?: RsbuildConfig;
477
- /**
478
- * Inject global components.
479
- */
480
- globalUIComponents?: (string | [string, object])[];
481
- /**
482
- * Modify doc config.
483
- */
484
- config?: (config: UserConfig, utils: {
485
- addPlugin: (plugin: RspressPlugin) => void;
486
- removePlugin: (pluginName: string) => void;
487
- }, isProd: boolean) => UserConfig | Promise<UserConfig>;
488
- /**
489
- * Callback before build
490
- */
491
- beforeBuild?: (config: UserConfig, isProd: boolean) => void | Promise<void>;
492
- /**
493
- * Callback after build
494
- */
495
- afterBuild?: (config: UserConfig, isProd: boolean) => void | Promise<void>;
496
- /**
497
- * Extend every page's data
498
- */
499
- extendPageData?: (pageData: PageIndexInfo, isProd: boolean) => void | Promise<void>;
500
- /**
501
- * Add custom route
502
- */
503
- addPages?: (config: UserConfig, isProd: boolean) => AdditionalPage[] | Promise<AdditionalPage[]>;
504
- /**
505
- * Add runtime modules
506
- */
507
- addRuntimeModules?: (config: UserConfig, isProd: boolean) => Record<string, string> | Promise<Record<string, string>>;
508
- /**
509
- * Callback after route generated
510
- */
511
- routeGenerated?: (routes: RouteMeta[], isProd: boolean) => Promise<void> | void;
512
- /**
513
- * Callback after routeService generated
514
- */
515
- routeServiceGenerated?: (routeService: any, isProd: boolean) => Promise<void> | void;
516
- /**
517
- * Add addition ssg routes, for dynamic routes.
518
- */
519
- addSSGRoutes?: (config: UserConfig, isProd: boolean) => {
520
- path: string;
521
- }[] | Promise<{
522
- path: string;
523
- }[]>;
524
- /**
525
- * @private
526
- * Modify search index data.
527
- */
528
- modifySearchIndexData?: (data: PageIndexInfo[], isProd: boolean) => void | Promise<void>;
529
- }
530
-
531
- declare interface SearchHooks {
532
- /**
533
- * The search hook function path. The corresponding file should export a function named `onSearch`.
534
- */
535
- searchHooks?: string;
536
- }
537
-
538
- declare type SearchOptions = LocalSearchOptions | RemoteSearchOptions | false;
539
-
540
- declare interface Sidebar {
541
- [path: string]: (SidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader)[];
542
- }
543
-
544
- declare type SidebarDivider = {
545
- dividerType: 'dashed' | 'solid';
546
- };
547
-
548
- declare interface SidebarGroup {
549
- text: string;
550
- link?: string;
551
- tag?: string;
552
- items: (SidebarItem | SidebarDivider | SidebarGroup | string)[];
553
- collapsible?: boolean;
554
- collapsed?: boolean;
555
- /**
556
- * For hmr usage in development
557
- */
558
- _fileKey?: string;
559
- overviewHeaders?: number[];
560
- context?: string;
561
- }
562
-
563
- declare type SidebarItem = {
564
- text: string;
565
- link: string;
566
- tag?: string;
567
- /**
568
- * For hmr usage in development
569
- */
570
- _fileKey?: string;
571
- overviewHeaders?: number[];
572
- context?: string;
573
- };
574
-
575
- declare type SidebarSectionHeader = {
576
- sectionHeaderText: string;
577
- tag?: string;
578
- };
579
-
580
- declare interface SocialLink {
581
- icon: SocialLinkIcon;
582
- mode: 'link' | 'text' | 'img' | 'dom';
583
- content: string;
584
- }
585
-
586
- declare type SocialLinkIcon = 'lark' | 'discord' | 'facebook' | 'github' | 'instagram' | 'linkedin' | 'slack' | 'x' | 'youtube' | 'wechat' | 'qq' | 'juejin' | 'zhihu' | 'bilibili' | 'weibo' | 'gitlab' | 'X' | 'bluesky' | {
587
- svg: string;
588
- };
589
-
590
- declare interface UserConfig<ThemeConfig = DefaultThemeConfig> {
591
- /**
592
- * The root directory of the site.
593
- * @default 'docs'
594
- */
595
- root?: string;
596
- /**
597
- * Path to the logo file in nav bar.
598
- */
599
- logo?: string | {
600
- dark: string;
601
- light: string;
602
- };
603
- /**
604
- * The text of the logo in nav bar.
605
- * @default ''
606
- */
607
- logoText?: string;
608
- /**
609
- * Base path of the site.
610
- * @default '/'
611
- */
612
- base?: string;
613
- /**
614
- * Path to html icon file.
615
- */
616
- icon?: string;
617
- /**
618
- * Default language of the site.
619
- */
620
- lang?: string;
621
- /**
622
- * Title of the site.
623
- * @default 'Rspress'
624
- */
625
- title?: string;
626
- /**
627
- * Description of the site.
628
- * @default ''
629
- */
630
- description?: string;
631
- /**
632
- * Head tags.
633
- */
634
- head?: (string | [string, Record<string, string>] | ((route: RouteMeta) => string | [string, Record<string, string>] | undefined))[];
635
- /**
636
- * I18n config of the site.
637
- */
638
- locales?: Locale[];
639
- /**
640
- * The i18n text data source path. Default is `i18n.json` in cwd.
641
- */
642
- i18nSourcePath?: string;
643
- /**
644
- * Theme config.
645
- */
646
- themeConfig?: ThemeConfig;
647
- /**
648
- * Rsbuild Configuration
649
- */
650
- builderConfig?: RsbuildConfig;
651
- /**
652
- * The custom config of vite-plugin-route
653
- */
654
- route?: RouteOptions;
655
- /**
656
- * The custom config of markdown compile
657
- */
658
- markdown?: MarkdownOptions;
659
- /**
660
- * Doc plugins
661
- */
662
- plugins?: RspressPlugin[];
663
- /**
664
- * Replace rule, will replace the content of the page.
665
- */
666
- replaceRules?: ReplaceRule[];
667
- /**
668
- * Output directory
669
- */
670
- outDir?: string;
671
- /**
672
- * Custom theme directory
673
- */
674
- themeDir?: string;
675
- /**
676
- * Global components
677
- */
678
- globalUIComponents?: (string | [string, object])[];
679
- /**
680
- * Global styles, is a Absolute path
681
- */
682
- globalStyles?: string;
683
- /**
684
- * Search options
685
- */
686
- search?: SearchOptions;
687
- /**
688
- * Whether to enable ssg, default is true
689
- */
690
- ssg?: boolean;
691
- /**
692
- * Whether to enable medium-zoom, default is true
693
- */
694
- mediumZoom?: boolean | {
695
- selector?: string;
696
- options?: ZoomOptions;
697
- };
698
- /**
699
- * Add some extra builder plugins
700
- */
701
- builderPlugins?: RsbuildPlugin[];
702
- /**
703
- * Multi version config
704
- */
705
- multiVersion?: {
706
- /**
707
- * The default version
708
- */
709
- default?: string;
710
- /**
711
- * The version list, such as ['v1', 'v2']
712
- */
713
- versions: string[];
714
- };
715
- /**
716
- * Language parity checking config
717
- */
718
- languageParity?: {
719
- /**
720
- * Whether to enable language parity checking
721
- */
722
- enabled?: boolean;
723
- /**
724
- * Directories to include in the parity check
725
- */
726
- include?: string[];
727
- /**
728
- * Directories to exclude from the parity check
729
- */
730
- exclude?: string[];
731
- };
732
- }
733
-
734
- declare interface ZoomContainer {
735
- width?: number
736
- height?: number
737
- top?: number
738
- bottom?: number
739
- right?: number
740
- left?: number
741
- }
742
-
743
- declare interface ZoomOptions {
744
- /**
745
- * The space outside the zoomed image.
746
- *
747
- * @default 0
748
- */
749
- margin?: number
750
-
751
- /**
752
- * The background of the overlay.
753
- *
754
- * @default '#fff'
755
- */
756
- background?: string
757
-
758
- /**
759
- * The number of pixels to scroll to close the zoom.
760
- *
761
- * @default 40
762
- */
763
- scrollOffset?: number
764
-
765
- /**
766
- * The viewport to render the zoom in.
767
- *
768
- * @default null
769
- */
770
- container?: string | HTMLElement | ZoomContainer
771
-
772
- /**
773
- * The template element to display on zoom.
774
- *
775
- * @default null
776
- */
777
- template?: string | HTMLTemplateElement
778
- }
779
-
780
52
  export { }