diff --git a/packages/@vuepress/types/src/config.ts b/packages/@vuepress/types/src/config.ts index b4f21168cc..243b9d7a07 100644 --- a/packages/@vuepress/types/src/config.ts +++ b/packages/@vuepress/types/src/config.ts @@ -1,16 +1,28 @@ import { PostCssLoaderOptions } from "./style"; import { MarkdownConfig } from "./markdown"; -import { LocaleConfig } from "./locale"; +import { Locales } from "./locale"; import { ThemeConfig } from "./theme"; import { UserPlugins } from "./plugin"; import { Context } from "./context"; import { ChainWebpack } from "./shared"; + /** * HTML tag name */ export type HTMLTagName = keyof HTMLElementTagNameMap; +/** + * Expose `HeadTags` + */ +export type HeadTags = Array< +[ + HTMLTagName, + Partial, + string? /* innerHTML */ +] +>; + /** * Expose `VuePress` config. */ @@ -39,13 +51,7 @@ export interface Config { * * @see https://vuepress.vuejs.org/config/#head */ - head?: Array< - [ - HTMLTagName, - Partial, - string? /* innerHTML */ - ] - >; + head?: HeadTags; /** * Specify the host to use for the dev server. * @@ -77,7 +83,7 @@ export interface Config { * * @see https://vuepress.vuejs.org/config/#locales */ - locales?: { [path: string]: LocaleConfig }; + locales?: Locales; /** * A function to control what files should have resource hints generated. * diff --git a/packages/@vuepress/types/src/context.ts b/packages/@vuepress/types/src/context.ts index 83ec112487..f188eab904 100644 --- a/packages/@vuepress/types/src/context.ts +++ b/packages/@vuepress/types/src/context.ts @@ -1,6 +1,7 @@ import { ThemeConfig } from "./theme"; import { Config } from "./config"; import { Lang } from "./lang"; +import { SiteData } from "./site-data"; /** * Page instance. @@ -173,4 +174,8 @@ export interface Context< * Theme API. */ themeAPI: ThemeAPI; + /** + * Get site data. + */ + getSiteData(): SiteData; } diff --git a/packages/@vuepress/types/src/locale.ts b/packages/@vuepress/types/src/locale.ts index 8ef8e55134..2ee50dd2a6 100644 --- a/packages/@vuepress/types/src/locale.ts +++ b/packages/@vuepress/types/src/locale.ts @@ -16,3 +16,5 @@ export interface LocaleConfig { */ description: string; } + +export type Locales = { [path: string]: LocaleConfig }; diff --git a/packages/@vuepress/types/src/site-data.ts b/packages/@vuepress/types/src/site-data.ts new file mode 100644 index 0000000000..e9496704f4 --- /dev/null +++ b/packages/@vuepress/types/src/site-data.ts @@ -0,0 +1,14 @@ +import { Page } from "./context"; +import { ThemeConfig } from "./theme"; +import { Locales } from "./locale"; +import { HeadTags } from "./config"; + +export interface SiteData { + title: string; + description: string; + base: string; + pages: Page[]; + headTags: HeadTags; + themeConfig: T; + locales: Locales; +}