doc.yeswiki.pro/node_modules/vitepress/dist/client/index.d.ts
2023-05-20 19:38:02 +03:00

99 lines
2.9 KiB
TypeScript

import * as vue from 'vue';
import { Component, Ref, App, AsyncComponentLoader } from 'vue';
import { PageData, Awaitable, SiteData } from '../../types/shared.js';
export { HeadConfig, Header, PageData, SiteData } from '../../types/shared.js';
declare const inBrowser: boolean;
interface Route {
path: string;
data: PageData;
component: Component | null;
}
interface Router {
route: Route;
go: (href?: string) => Promise<void>;
onBeforeRouteChange?: (to: string) => Awaitable<void>;
onAfterRouteChanged?: (to: string) => Awaitable<void>;
}
declare function useRouter(): Router;
declare function useRoute(): Route;
interface VitePressData<T = any> {
/**
* Site-level metadata
*/
site: Ref<SiteData<T>>;
/**
* themeConfig from .vitepress/config.js
*/
theme: Ref<T>;
/**
* Page-level metadata
*/
page: Ref<PageData>;
/**
* page frontmatter data
*/
frontmatter: Ref<PageData['frontmatter']>;
/**
* dynamic route params
*/
params: Ref<PageData['params']>;
title: Ref<string>;
description: Ref<string>;
lang: Ref<string>;
isDark: Ref<boolean>;
dir: Ref<string>;
localeIndex: Ref<string>;
}
declare function useData<T = any>(): VitePressData<T>;
interface EnhanceAppContext {
app: App;
router: Router;
siteData: Ref<SiteData>;
}
interface Theme {
Layout: Component;
enhanceApp?: (ctx: EnhanceAppContext) => Awaitable<void>;
extends?: Theme;
/**
* @deprecated can be replaced by wrapping layout component
*/
setup?: () => void;
/**
* @deprecated Render not found page by checking `useData().page.value.isNotFound` in Layout instead.
*/
NotFound?: Component;
}
declare function withBase(path: string): string;
/**
* Register callback that is called every time the markdown content is updated
* in the DOM.
*/
declare function onContentUpdated(fn: () => any): void;
declare function defineClientComponent(loader: AsyncComponentLoader, args?: any[], cb?: () => Awaitable<void>): {
setup(): () => vue.VNode<vue.RendererNode, vue.RendererElement, {
[key: string]: any;
}> | null;
};
declare const Content: vue.DefineComponent<{
as: {
type: (ObjectConstructor | StringConstructor)[];
default: string;
};
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
[key: string]: any;
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
as: {
type: (ObjectConstructor | StringConstructor)[];
default: string;
};
}>>, {
as: string | Record<string, any>;
}, {}>;
export { Content, EnhanceAppContext, Route, Router, Theme, VitePressData, defineClientComponent, inBrowser, onContentUpdated, useData, useRoute, useRouter, withBase };