@rspress-theme-anatole/shared 0.0.1

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