fix: properly type vitepress/theme

pull/494/head
Divyansh Singh 4 years ago
parent 4109acf67e
commit 565fc9e871

@ -11,7 +11,8 @@
"bin", "bin",
"dist", "dist",
"types", "types",
"client.d.ts" "client.d.ts",
"theme.d.ts"
], ],
"scripts": { "scripts": {
"dev": "run-s dev-shared dev-start", "dev": "run-s dev-shared dev-start",

@ -33,7 +33,9 @@ function createContainer(klass: string, defaultTitle: string): ContainerArgs {
const info = token.info.trim().slice(klass.length).trim() const info = token.info.trim().slice(klass.length).trim()
if (token.nesting === 1) { if (token.nesting === 1) {
if (klass === 'details') { if (klass === 'details') {
return `<details class="${klass} custom-block">${info ? `<summary>${info}</summary>` : ''}\n` return `<details class="${klass} custom-block">${
info ? `<summary>${info}</summary>` : ''
}\n`
} }
return `<div class="${klass} custom-block"><p class="custom-block-title">${ return `<div class="${klass} custom-block"><p class="custom-block-title">${
info || defaultTitle info || defaultTitle

@ -23,7 +23,7 @@ export interface ServeOptions {
export async function serve(options: ServeOptions = {}) { export async function serve(options: ServeOptions = {}) {
const port = options.port !== undefined ? options.port : 5000 const port = options.port !== undefined ? options.port : 5000
const site = await resolveConfig(options.root, 'serve', 'production') const site = await resolveConfig(options.root, 'serve', 'production')
const base = trimChar(site?.site?.base ?? "", "/") const base = trimChar(site?.site?.base ?? '', '/')
const compress = compression() const compress = compression()
const serve = sirv(site.outDir, { const serve = sirv(site.outDir, {

@ -6,7 +6,7 @@ export type {
HeadConfig, HeadConfig,
LocaleConfig, LocaleConfig,
Header, Header,
DefaultTheme, DefaultTheme
} from '../../types/shared' } from '../../types/shared'
export const EXTERNAL_URL_RE = /^https?:/i export const EXTERNAL_URL_RE = /^https?:/i

5
theme.d.ts vendored

@ -1,3 +1,4 @@
// so that users can do `import DefaultTheme from 'vitepress/theme'` // so that users can do `import DefaultTheme from 'vitepress/theme'`
import DefaultTheme from './dist/client/theme-default/index' import { Theme } from 'vitepress'
export default DefaultTheme declare const theme: Theme
export default theme

Loading…
Cancel
Save