mirror of https://github.com/vuejs/vitepress
Merge branch 'main' of https://github.com/vuejs/vitepress into vuejs-main
commit
b89a88d61c
@ -1,146 +1 @@
|
||||
export namespace DefaultTheme {
|
||||
export interface Config {
|
||||
logo?: string
|
||||
nav?: NavItem[] | false
|
||||
sidebar?: SideBarConfig | MultiSideBarConfig
|
||||
|
||||
/**
|
||||
* GitHub repository following the format <user>/<project>.
|
||||
*
|
||||
* @example `"vuejs/vue-next"`
|
||||
*/
|
||||
repo?: string
|
||||
|
||||
/**
|
||||
* Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
|
||||
* depending on the provided repo.
|
||||
*
|
||||
* @example `"Contribute!"`
|
||||
*/
|
||||
repoLabel?: string
|
||||
|
||||
/**
|
||||
* If your docs are in a different repository from your main project.
|
||||
*
|
||||
* @example `"vuejs/docs-next"`
|
||||
*/
|
||||
docsRepo?: string
|
||||
|
||||
/**
|
||||
* If your docs are not at the root of the repo.
|
||||
*
|
||||
* @example `"docs"`
|
||||
*/
|
||||
docsDir?: string
|
||||
|
||||
/**
|
||||
* If your docs are in a different branch. Defaults to `master`.
|
||||
*
|
||||
* @example `"next"`
|
||||
*/
|
||||
docsBranch?: string
|
||||
|
||||
/**
|
||||
* Enable links to edit pages at the bottom of the page.
|
||||
*/
|
||||
editLinks?: boolean
|
||||
|
||||
/**
|
||||
* Custom text for edit link. Defaults to "Edit this page".
|
||||
*/
|
||||
editLinkText?: string
|
||||
|
||||
/**
|
||||
* Show last updated time at the bottom of the page. Defaults to `false`.
|
||||
* If given a string, it will be displayed as a prefix (default value:
|
||||
* "Last Updated").
|
||||
*/
|
||||
lastUpdated?: string | boolean
|
||||
|
||||
prevLinks?: boolean
|
||||
nextLinks?: boolean
|
||||
|
||||
locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
|
||||
|
||||
algolia?: AlgoliaSearchOptions
|
||||
|
||||
carbonAds?: {
|
||||
carbon: string
|
||||
custom?: string
|
||||
placement: string
|
||||
}
|
||||
}
|
||||
|
||||
// navbar --------------------------------------------------------------------
|
||||
|
||||
export type NavItem = NavItemWithLink | NavItemWithChildren
|
||||
|
||||
export interface NavItemBase {
|
||||
text: string
|
||||
target?: string
|
||||
rel?: string
|
||||
ariaLabel?: string
|
||||
activeMatch?: string
|
||||
}
|
||||
|
||||
export interface NavItemWithLink extends NavItemBase {
|
||||
link: string
|
||||
}
|
||||
|
||||
export interface NavItemWithChildren extends NavItemBase {
|
||||
items: NavItemWithLink[]
|
||||
}
|
||||
|
||||
// sidebar -------------------------------------------------------------------
|
||||
|
||||
export type SideBarConfig = SideBarItem[] | 'auto' | false
|
||||
|
||||
export interface MultiSideBarConfig {
|
||||
[path: string]: SideBarConfig
|
||||
}
|
||||
|
||||
export type SideBarItem = SideBarLink | SideBarGroup
|
||||
|
||||
export interface SideBarLink {
|
||||
text: string
|
||||
link: string
|
||||
}
|
||||
|
||||
export interface SideBarGroup {
|
||||
text: string
|
||||
link?: string
|
||||
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
collapsable?: boolean
|
||||
|
||||
children: SideBarItem[]
|
||||
}
|
||||
|
||||
// algolia ------------------------------------------------------------------
|
||||
// partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
|
||||
export interface AlgoliaSearchOptions {
|
||||
appId?: string
|
||||
apiKey: string
|
||||
indexName: string
|
||||
placeholder?: string
|
||||
searchParameters?: any
|
||||
disableUserPersonalization?: boolean
|
||||
initialQuery?: string
|
||||
}
|
||||
|
||||
// locales -------------------------------------------------------------------
|
||||
|
||||
export interface LocaleConfig {
|
||||
/**
|
||||
* Text for the language dropdown.
|
||||
*/
|
||||
selectText?: string
|
||||
|
||||
/**
|
||||
* Label for this locale in the language dropdown.
|
||||
*/
|
||||
label?: string
|
||||
}
|
||||
}
|
||||
export { DefaultTheme } from '../shared'
|
||||
|
@ -1,16 +1,16 @@
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import { MarkdownParsedData } from '../markdown'
|
||||
import { MarkdownRenderer } from '../markdown'
|
||||
import { deeplyParseHeader } from '../../utils/parseHeader'
|
||||
import { slugify } from './slugify'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
|
||||
export const extractHeaderPlugin = (md: MarkdownIt, include = ['h2', 'h3']) => {
|
||||
export const headingPlugin = (md: MarkdownIt, include = ['h2', 'h3']) => {
|
||||
md.renderer.rules.heading_open = (tokens, i, options, env, self) => {
|
||||
const token = tokens[i]
|
||||
if (include.includes(token.tag)) {
|
||||
const title = tokens[i + 1].content
|
||||
const idAttr = token.attrs!.find(([name]) => name === 'id')
|
||||
const slug = idAttr && idAttr[1]
|
||||
const data = (md as any).__data as MarkdownParsedData
|
||||
const data = (md as MarkdownRenderer).__data
|
||||
const headers = data.headers || (data.headers = [])
|
||||
headers.push({
|
||||
level: parseInt(token.tag.slice(1), 10),
|
@ -0,0 +1,146 @@
|
||||
export namespace DefaultTheme {
|
||||
export interface Config {
|
||||
logo?: string
|
||||
nav?: NavItem[] | false
|
||||
sidebar?: SideBarConfig | MultiSideBarConfig
|
||||
|
||||
/**
|
||||
* GitHub repository following the format <user>/<project>.
|
||||
*
|
||||
* @example `"vuejs/vue-next"`
|
||||
*/
|
||||
repo?: string
|
||||
|
||||
/**
|
||||
* Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
|
||||
* depending on the provided repo.
|
||||
*
|
||||
* @example `"Contribute!"`
|
||||
*/
|
||||
repoLabel?: string
|
||||
|
||||
/**
|
||||
* If your docs are in a different repository from your main project.
|
||||
*
|
||||
* @example `"vuejs/docs-next"`
|
||||
*/
|
||||
docsRepo?: string
|
||||
|
||||
/**
|
||||
* If your docs are not at the root of the repo.
|
||||
*
|
||||
* @example `"docs"`
|
||||
*/
|
||||
docsDir?: string
|
||||
|
||||
/**
|
||||
* If your docs are in a different branch. Defaults to `master`.
|
||||
*
|
||||
* @example `"next"`
|
||||
*/
|
||||
docsBranch?: string
|
||||
|
||||
/**
|
||||
* Enable links to edit pages at the bottom of the page.
|
||||
*/
|
||||
editLinks?: boolean
|
||||
|
||||
/**
|
||||
* Custom text for edit link. Defaults to "Edit this page".
|
||||
*/
|
||||
editLinkText?: string
|
||||
|
||||
/**
|
||||
* Show last updated time at the bottom of the page. Defaults to `false`.
|
||||
* If given a string, it will be displayed as a prefix (default value:
|
||||
* "Last Updated").
|
||||
*/
|
||||
lastUpdated?: string | boolean
|
||||
|
||||
prevLinks?: boolean
|
||||
nextLinks?: boolean
|
||||
|
||||
locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
|
||||
|
||||
algolia?: AlgoliaSearchOptions
|
||||
|
||||
carbonAds?: {
|
||||
carbon: string
|
||||
custom?: string
|
||||
placement: string
|
||||
}
|
||||
}
|
||||
|
||||
// navbar --------------------------------------------------------------------
|
||||
|
||||
export type NavItem = NavItemWithLink | NavItemWithChildren
|
||||
|
||||
export interface NavItemBase {
|
||||
text: string
|
||||
target?: string
|
||||
rel?: string
|
||||
ariaLabel?: string
|
||||
activeMatch?: string
|
||||
}
|
||||
|
||||
export interface NavItemWithLink extends NavItemBase {
|
||||
link: string
|
||||
}
|
||||
|
||||
export interface NavItemWithChildren extends NavItemBase {
|
||||
items: NavItemWithLink[]
|
||||
}
|
||||
|
||||
// sidebar -------------------------------------------------------------------
|
||||
|
||||
export type SideBarConfig = SideBarItem[] | 'auto' | false
|
||||
|
||||
export interface MultiSideBarConfig {
|
||||
[path: string]: SideBarConfig
|
||||
}
|
||||
|
||||
export type SideBarItem = SideBarLink | SideBarGroup
|
||||
|
||||
export interface SideBarLink {
|
||||
text: string
|
||||
link: string
|
||||
}
|
||||
|
||||
export interface SideBarGroup {
|
||||
text: string
|
||||
link?: string
|
||||
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
collapsable?: boolean
|
||||
|
||||
children: SideBarItem[]
|
||||
}
|
||||
|
||||
// algolia ------------------------------------------------------------------
|
||||
// partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
|
||||
export interface AlgoliaSearchOptions {
|
||||
appId?: string
|
||||
apiKey: string
|
||||
indexName: string
|
||||
placeholder?: string
|
||||
searchParameters?: any
|
||||
disableUserPersonalization?: boolean
|
||||
initialQuery?: string
|
||||
}
|
||||
|
||||
// locales -------------------------------------------------------------------
|
||||
|
||||
export interface LocaleConfig {
|
||||
/**
|
||||
* Text for the language dropdown.
|
||||
*/
|
||||
selectText?: string
|
||||
|
||||
/**
|
||||
* Label for this locale in the language dropdown.
|
||||
*/
|
||||
label?: string
|
||||
}
|
||||
}
|
Loading…
Reference in new issue