-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(types):
defineThemeEntry
helper to infer type for theme entry
- Loading branch information
Showing
10 changed files
with
114 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,55 @@ | ||
import { Plugins } from "./plugin"; | ||
import { Context } from "./context"; | ||
import { Config } from "./config"; | ||
|
||
/** | ||
* Default theme config type | ||
*/ | ||
export type ThemeConfig = any; | ||
|
||
/** | ||
* Export type of theme entry | ||
* | ||
* @see https://vuepress.vuejs.org/theme/option-api.html | ||
*/ | ||
export type ThemeEntry = { | ||
/** | ||
* plugins | ||
*/ | ||
plugins?: Plugins; | ||
/** | ||
* HTML template path used in dev mode. | ||
* | ||
* @default https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/client/index.dev.html | ||
* @see https://vuepress.vuejs.org/theme/option-api.html#devtemplate | ||
*/ | ||
devTemplate?: string; | ||
/** | ||
* HTML template path used in build mode | ||
* | ||
* @default https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/client/index.ssr.html | ||
* @see https://vuepress.vuejs.org/theme/option-api.html#ssrtemplate | ||
*/ | ||
ssrTemplate?: string; | ||
/** | ||
* Extends a theme | ||
* | ||
* @see https://vuepress.vuejs.org/theme/option-api.html#extend | ||
*/ | ||
extend?: string; | ||
/** | ||
* Global layout component is a component responsible for the global layout strategy. | ||
* | ||
* @see https://vuepress.vuejs.org/theme/option-api.html#globallayout | ||
*/ | ||
globalLayout?: string; | ||
}; | ||
|
||
/** | ||
* Export type of theme entry with function support | ||
* | ||
* @see https://vuepress.vuejs.org/theme/option-api.html | ||
*/ | ||
export type UserThemeEntry<T extends ThemeConfig = ThemeConfig> = | ||
| ThemeEntry | ||
| ((themeConfig: T, ctx: Context<T, Config<T>>) => ThemeEntry); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
import { Context, Config, ThemeConfig, DefaultThemeConfig } from '@vuepress/types' | ||
import { | ||
UserConfig, | ||
ThemeConfig, | ||
DefaultThemeConfig, | ||
ThemeEntry | ||
} from '@vuepress/types' | ||
|
||
export * from '@vuepress/types' | ||
|
||
export type UserConfig<T extends ThemeConfig> = | ||
| Config<T> | ||
| ((ctx: Context) => Config<T>); | ||
|
||
/** | ||
* Helper for type prompt and type checking. | ||
* A helper function to define VuePress config file. | ||
* | ||
* @see https://vuepress.vuejs.org/config/ | ||
*/ | ||
export function defineConfig(config: UserConfig<DefaultThemeConfig>): void; | ||
|
||
/** | ||
* A helper function to define VuePress config file, for custom theme. | ||
* | ||
* @see https://vuepress.vuejs.org/config/ | ||
*/ | ||
export function defineConfig4CustomTheme<T extends ThemeConfig = ThemeConfig>( | ||
config: UserConfig<T> | ||
): void; | ||
|
||
/** | ||
* A helper function to define VuePress theme entry file. | ||
* | ||
* @see https://vuepress.vuejs.org/theme/option-api.html | ||
*/ | ||
export function defineThemeEntry(config: ThemeEntry): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
exports.defineConfig = function (config) { | ||
return config | ||
} | ||
exports.defineConfig4CustomTheme = function (config) { | ||
return config | ||
function define (config) { | ||
config | ||
} | ||
exports.defineConfig = define | ||
exports.defineConfig4CustomTheme = define | ||
exports.defineThemeEntry = define |