1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import {Loader, Configuration} from 'webpack';
|
9 | import {Command} from 'commander';
|
10 | import {ParsedUrlQueryInput} from 'querystring';
|
11 |
|
12 | export interface DocusaurusConfig {
|
13 | baseUrl: string;
|
14 | favicon: string;
|
15 | tagline: string;
|
16 | title: string;
|
17 | url: string;
|
18 | organizationName?: string;
|
19 | projectName?: string;
|
20 | githubHost?: string;
|
21 | plugins?: PluginConfig[];
|
22 | themes?: PluginConfig[];
|
23 | presets?: PresetConfig[];
|
24 | themeConfig?: {
|
25 | [key: string]: any;
|
26 | };
|
27 | customFields?: {
|
28 | [key: string]: any;
|
29 | };
|
30 | scripts?: (
|
31 | | string
|
32 | | {
|
33 | src: string;
|
34 | [key: string]: any;
|
35 | }
|
36 | )[];
|
37 | stylesheets?: (
|
38 | | string
|
39 | | {
|
40 | href: string;
|
41 | [key: string]: any;
|
42 | }
|
43 | )[];
|
44 | }
|
45 |
|
46 | export interface DocusaurusContext {
|
47 | siteConfig?: DocusaurusConfig;
|
48 | }
|
49 |
|
50 | export interface Preset {
|
51 | plugins?: PluginConfig[];
|
52 | themes?: PluginConfig[];
|
53 | }
|
54 |
|
55 | export type PresetConfig = [string, Object] | [string] | string;
|
56 |
|
57 | export interface StartCLIOptions {
|
58 | port: string;
|
59 | host: string;
|
60 | hotOnly: boolean;
|
61 | open: boolean;
|
62 | }
|
63 |
|
64 | export interface BuildCLIOptions {
|
65 | bundleAnalyzer: boolean;
|
66 | }
|
67 |
|
68 | export interface LoadContext {
|
69 | siteDir: string;
|
70 | generatedFilesDir: string;
|
71 | siteConfig: DocusaurusConfig;
|
72 | outDir: string;
|
73 | baseUrl: string;
|
74 | }
|
75 |
|
76 | export interface InjectedHtmlTags {
|
77 | headTags: string;
|
78 | preBodyTags: string;
|
79 | postBodyTags: string;
|
80 | }
|
81 |
|
82 | export type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[];
|
83 |
|
84 | export interface Props extends LoadContext, InjectedHtmlTags {
|
85 | routesPaths: string[];
|
86 | plugins: Plugin<any>[];
|
87 | }
|
88 |
|
89 | export interface PluginContentLoadedActions {
|
90 | addRoute(config: RouteConfig): void;
|
91 | createData(name: string, data: any): Promise<string>;
|
92 | }
|
93 |
|
94 | export interface Plugin<T> {
|
95 | name: string;
|
96 | loadContent?(): Promise<T>;
|
97 | contentLoaded?({
|
98 | content,
|
99 | actions,
|
100 | }: {
|
101 | content: T;
|
102 | actions: PluginContentLoadedActions;
|
103 | }): void;
|
104 | postBuild?(props: Props): void;
|
105 | postStart?(props: Props): void;
|
106 | configureWebpack?(
|
107 | config: Configuration,
|
108 | isServer: boolean,
|
109 | utils: ConfigureWebpackUtils,
|
110 | ): Configuration;
|
111 | getThemePath?(): string;
|
112 | getPathsToWatch?(): string[];
|
113 | getClientModules?(): string[];
|
114 | extendCli?(cli: Command): void;
|
115 | injectHtmlTags?(): {
|
116 | headTags?: HtmlTags;
|
117 | preBodyTags?: HtmlTags;
|
118 | postBodyTags?: HtmlTags;
|
119 | };
|
120 | }
|
121 |
|
122 | export type PluginConfig = [string, Object] | [string] | string;
|
123 |
|
124 | export interface ChunkRegistry {
|
125 | loader: string;
|
126 | modulePath: string;
|
127 | }
|
128 |
|
129 | export type Module =
|
130 | | {
|
131 | path: string;
|
132 | __import?: boolean;
|
133 | query?: ParsedUrlQueryInput;
|
134 | }
|
135 | | string;
|
136 |
|
137 | export interface RouteModule {
|
138 | [module: string]: Module | RouteModule | RouteModule[];
|
139 | }
|
140 |
|
141 | export interface ChunkNames {
|
142 | [name: string]: string | null | ChunkNames | ChunkNames[];
|
143 | }
|
144 |
|
145 | export interface RouteConfig {
|
146 | path: string;
|
147 | component: string;
|
148 | modules?: RouteModule;
|
149 | routes?: RouteConfig[];
|
150 | exact?: boolean;
|
151 | priority?: number;
|
152 | }
|
153 |
|
154 | export interface ThemeAlias {
|
155 | [alias: string]: string;
|
156 | }
|
157 |
|
158 | export interface ConfigureWebpackUtils {
|
159 | getStyleLoaders: (
|
160 | isServer: boolean,
|
161 | cssOptions: {
|
162 | [key: string]: any;
|
163 | },
|
164 | ) => Loader[];
|
165 | getCacheLoader: (isServer: boolean, cacheOptions?: {}) => Loader | null;
|
166 | getBabelLoader: (isServer: boolean, babelOptions?: {}) => Loader;
|
167 | }
|
168 |
|
169 | interface HtmlTagObject {
|
170 | |
171 |
|
172 |
|
173 |
|
174 | attributes?: {
|
175 | [attributeName: string]: string | boolean;
|
176 | };
|
177 | |
178 |
|
179 |
|
180 | tagName: string;
|
181 | |
182 |
|
183 |
|
184 | innerHTML?: string;
|
185 | }
|