UNPKG

5.68 kBTypeScriptView Raw
1import type { ExampleBlockAsset } from 'dumi-assets-types';
2import type { ComponentType, ReactNode } from 'react';
3export interface IPreviewerProps {
4 /**
5 * title of current demo
6 */
7 title?: string;
8 /**
9 * description of current demo
10 */
11 description?: string;
12 /**
13 * filename of current demo
14 */
15 filename?: string;
16 /**
17 * use iframe to render demo
18 */
19 iframe?: boolean | number;
20 /**
21 * debug mark (will only render in dev by default)
22 */
23 debug?: boolean;
24 /**
25 * display the source code or not by default
26 */
27 defaultShowCode?: boolean;
28 /**
29 * url for render current demo in a single page
30 */
31 demoUrl: string;
32 /**
33 * disable demo content padding
34 */
35 compact?: boolean;
36 /**
37 * add transform property for handle absolute/fixed position element
38 */
39 transform?: boolean;
40 /**
41 * background color for demo content
42 */
43 background?: string;
44 /**
45 * asset metadata of current demo
46 */
47 asset: ExampleBlockAsset;
48 /**
49 * react node of current demo
50 */
51 children: ReactNode;
52 [key: string]: any;
53}
54export interface IRouteMeta {
55 frontmatter: {
56 title: string;
57 description?: string;
58 keywords?: string[];
59 nav?: string | {
60 title?: string;
61 order?: number;
62 second?: Omit<IRouteMeta['frontmatter']['nav'], 'second'>;
63 };
64 group?: string | {
65 title?: string;
66 order?: number;
67 };
68 order?: number;
69 hero?: {
70 title?: string;
71 description?: string;
72 background?: string;
73 actions?: {
74 text: string;
75 link: string;
76 }[];
77 [key: string]: any;
78 };
79 features?: {
80 emoji?: string;
81 title?: string;
82 link?: string;
83 description?: string;
84 [key: string]: any;
85 }[];
86 toc?: boolean | 'content' | 'menu';
87 demo?: {
88 cols?: number;
89 tocDepth?: number;
90 };
91 atomId?: string;
92 filename?: string;
93 lastUpdated?: number;
94 debug?: boolean;
95 /**
96 * Control the display of the sidebar menu.
97 * @default true
98 */
99 sidebar?: boolean;
100 [key: string]: any;
101 };
102 toc: {
103 id: string;
104 depth: number;
105 title: string;
106 /**
107 * private field, do not use it in your code
108 */
109 _debug_demo?: boolean;
110 }[];
111 texts: {
112 type?: 'content';
113 value: string;
114 /**
115 * paragraph index
116 */
117 paraId: number;
118 /**
119 * title index in toc
120 */
121 tocIndex?: number;
122 }[];
123 tabs?: {
124 key: string;
125 title?: string;
126 titleIntlId?: string;
127 components: {
128 default: ComponentType;
129 Extra: ComponentType;
130 Action: ComponentType;
131 };
132 meta: {
133 frontmatter: Omit<IRouteMeta['frontmatter'], 'description' | 'keywords' | 'nav' | 'group' | 'hero' | 'features'>;
134 toc: IRouteMeta['toc'];
135 texts: IRouteMeta['texts'];
136 [key: string]: any;
137 };
138 }[];
139 /**
140 * private field, do not use it in your code
141 */
142 _atom_route?: boolean;
143}
144type IBasicLocale = {
145 id: string;
146 name: string;
147};
148export type ILocale = (IBasicLocale & {
149 base: string;
150}) | (IBasicLocale & {
151 suffix: string;
152});
153export type ILocalesConfig = ILocale[];
154export interface INavItem {
155 title: string;
156 link?: string;
157 order?: number;
158 activePath?: string;
159 [key: string]: any;
160}
161export interface ISidebarItem {
162 title: string;
163 link: string;
164 order?: number;
165 frontmatter?: IRouteMeta['frontmatter'];
166 [key: string]: any;
167}
168export interface ISidebarGroup {
169 title?: string;
170 children: ISidebarItem[];
171 [key: string]: any;
172}
173export type SocialTypes = 'github' | 'weibo' | 'twitter' | 'gitlab' | 'facebook' | 'zhihu' | 'yuque' | 'linkedin';
174export type INavItems = (INavItem & {
175 children?: INavItem[];
176})[];
177export type INav = INavItems | Record<string, INavItems>;
178type IUserNavItem = Pick<INavItem, 'title' | 'link' | 'activePath'>;
179export type IUserNavMode = 'override' | 'append' | 'prepend';
180export type IUserNavItems = (IUserNavItem & {
181 children?: IUserNavItem[];
182})[];
183export type IUserNavValue = IUserNavItems | Record<string, IUserNavItems>;
184export type NavWithMode<T extends IUserNavValue> = {
185 /**
186 * 扩展导航的模式
187 * @description
188 * - 'override': 用 value 中配置的导航直接覆盖约定路由的导航
189 * - 'append': 将 value 中配置的导航追加到约定路由导航后面
190 * - 'prepend': 将 value 中配置的导航添加到约定路由导航前面
191 */
192 mode: IUserNavMode;
193 value: T;
194};
195export interface IThemeConfig {
196 name?: string;
197 logo?: string | false;
198 nav?: IUserNavValue | NavWithMode<IUserNavValue>;
199 sidebar?: Record<string, ISidebarGroup[]>;
200 footer?: string | false;
201 showLineNum?: boolean;
202 prefersColor: {
203 default: 'light' | 'dark' | 'auto';
204 switch: boolean;
205 };
206 nprogress?: boolean;
207 socialLinks?: {
208 [key in SocialTypes]?: string;
209 };
210 editLink?: boolean | string;
211 lastUpdated?: boolean;
212 [key: string]: any;
213}
214export type IRoutesById = Record<string, {
215 path?: string;
216 parentId?: string;
217 meta?: IRouteMeta;
218 id: string;
219 redirect?: string;
220 [key: string]: any;
221}>;
222export {};