Merge branch 'main' into doc-zh

pull/2249/head
Xavi Lee 2 years ago committed by GitHub
commit 4dd71595bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,14 +1,12 @@
# VitePress (RC: release candidate) 📝💨
# VitePress 📝💨
[![Test](https://github.com/vuejs/vitepress/workflows/Test/badge.svg)](https://github.com/vuejs/vitepress/actions)
[![test](https://github.com/vuejs/vitepress/workflows/Test/badge.svg)](https://github.com/vuejs/vitepress/actions)
[![npm](https://img.shields.io/npm/v/vitepress)](https://www.npmjs.com/package/vitepress)
[![chat](https://img.shields.io/badge/chat-discord-blue?logo=discord)](https://chat.vuejs.org)
---
VitePress is [VuePress](https://vuepress.vuejs.org)' spiritual successor, built on top of [vite](https://github.com/vitejs/vite).
Currently, it is in the `release candidate` stage. It is already suitable for out-of-the-box documentation use. We do not plan to introduce any breaking changes from here on until the stable release.
VitePress is a Vue-powered static site generator and a spiritual successor to [VuePress](https://vuepress.vuejs.org), built on top of [Vite](https://github.com/vitejs/vite).
## Documentation

@ -1,4 +1,5 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useData } from '../composables/data'
import { useLangs } from '../composables/langs'
import { useSidebar } from '../composables/sidebar'
@ -8,11 +9,34 @@ import VPImage from './VPImage.vue'
const { site, theme } = useData()
const { hasSidebar } = useSidebar()
const { currentLang } = useLangs()
const link = computed(() =>
typeof theme.value.logoLink === 'string'
? theme.value.logoLink
: theme.value.logoLink?.link
)
const rel = computed(() =>
typeof theme.value.logoLink === 'string'
? undefined
: theme.value.logoLink?.rel
)
const target = computed(() =>
typeof theme.value.logoLink === 'string'
? undefined
: theme.value.logoLink?.target
)
</script>
<template>
<div class="VPNavBarTitle" :class="{ 'has-sidebar': hasSidebar }">
<a class="title" :href="theme.logoLink ?? normalizeLink(currentLang.link)">
<a
class="title"
:href="link ?? normalizeLink(currentLang.link)"
:rel="rel"
:target="target"
>
<slot name="nav-bar-title-before" />
<VPImage v-if="theme.logo" class="logo" :image="theme.logo" />
<template v-if="theme.siteTitle">{{ theme.siteTitle }}</template>

@ -127,6 +127,15 @@ export interface MarkdownOptions extends MarkdownIt.Options {
allowedAttributes?: Array<string | RegExp>
disable?: boolean
}
/**
* Options for `markdown-it-emoji`
* @see https://github.com/markdown-it/markdown-it-emoji
*/
emoji?: {
defs?: Record<string, string>
enabled?: string[]
shortcuts?: Record<string, string | string[]>
}
/**
* Options for `@mdit-vue/plugin-frontmatter`
* @see https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-frontmatter
@ -211,7 +220,7 @@ export const createMarkdownRenderer = async (
if (!options.attrs?.disable) {
md.use(attrsPlugin, options.attrs)
}
md.use(emojiPlugin)
md.use(emojiPlugin, { ...options.emoji })
// mdit-vue plugins
md.use(anchorPlugin, {

@ -147,13 +147,6 @@ export async function highlight(
return s
}
const fillEmptyHighlightedLine = (s: string) => {
return s.replace(
/(<span class="line highlighted">)(<\/span>)/g,
'$1<wbr>$2'
)
}
str = removeMustache(str).trimEnd()
const highlighted = highlighter.codeToHtml(str, {
@ -167,6 +160,31 @@ export async function highlight(
if (vPre) node.properties['v-pre'] = ''
}
},
{
name: 'vitepress:empty-line',
pre(hast) {
hast.children.forEach((code) => {
if (code.type === 'element' && code.tagName === 'code') {
code.children.forEach((span) => {
if (
span.type === 'element' &&
span.tagName === 'span' &&
Array.isArray(span.properties.class) &&
span.properties.class.includes('line') &&
span.children.length === 0
) {
span.children.push({
type: 'element',
tagName: 'wbr',
properties: {},
children: []
})
}
})
}
})
}
},
...userTransformers
],
meta: { __raw: attrs },
@ -175,6 +193,6 @@ export async function highlight(
: { theme })
})
return fillEmptyHighlightedLine(restoreMustache(highlighted))
return restoreMustache(highlighted)
}
}

@ -20,7 +20,7 @@ export namespace DefaultTheme {
/**
* Overrides the link of the site logo.
*/
logoLink?: string
logoLink?: string | { link?: string; rel?: string; target?: string }
/**
* Custom site title in navbar. If the value is undefined,
@ -174,8 +174,8 @@ export namespace DefaultTheme {
* RegExp object here because it isn't serializable
*/
activeMatch?: string
target?: string
rel?: string
target?: string
}
export interface NavItemChildren {

Loading…
Cancel
Save