From 2c4f27102becea0d69b8bd5fa080222a73482f74 Mon Sep 17 00:00:00 2001
From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Date: Sun, 31 Dec 2023 12:06:16 +0530
Subject: [PATCH 1/6] docs: prepare for stable
---
README.md | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index a8ccec37..2e70a766 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,12 @@
-# VitePress (RC: release candidate) 📝💨
+# VitePress 📝💨
-[](https://github.com/vuejs/vitepress/actions)
+[](https://github.com/vuejs/vitepress/actions)
[](https://www.npmjs.com/package/vitepress)
[](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
From 6c899437c15b126b488e73c99cdaad77fc7e5611 Mon Sep 17 00:00:00 2001
From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Date: Sun, 31 Dec 2023 12:46:16 +0530
Subject: [PATCH 2/6] feat(theme): allow specifying rel and target in logoLink
closes #3264
closes #3271
---
.../components/VPNavBarTitle.vue | 26 ++++++++++++++++++-
types/default-theme.d.ts | 4 +--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/client/theme-default/components/VPNavBarTitle.vue b/src/client/theme-default/components/VPNavBarTitle.vue
index 51f4233c..eadef086 100644
--- a/src/client/theme-default/components/VPNavBarTitle.vue
+++ b/src/client/theme-default/components/VPNavBarTitle.vue
@@ -1,4 +1,5 @@
-
+
{{ theme.siteTitle }}
diff --git a/types/default-theme.d.ts b/types/default-theme.d.ts
index be5cd0d3..fc8d4343 100644
--- a/types/default-theme.d.ts
+++ b/types/default-theme.d.ts
@@ -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 {
From 563020ba61abda254af9a124ddafd12de644cd4e Mon Sep 17 00:00:00 2001
From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Date: Sun, 31 Dec 2023 12:56:32 +0530
Subject: [PATCH 3/6] fix: fill all empty code lines
closes #3305
---
src/node/markdown/plugins/highlight.ts | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/node/markdown/plugins/highlight.ts b/src/node/markdown/plugins/highlight.ts
index f95a78b0..d185d7db 100644
--- a/src/node/markdown/plugins/highlight.ts
+++ b/src/node/markdown/plugins/highlight.ts
@@ -147,11 +147,8 @@ export async function highlight(
return s
}
- const fillEmptyHighlightedLine = (s: string) => {
- return s.replace(
- /()(<\/span>)/g,
- '$1$2'
- )
+ const fillEmptyLines = (s: string) => {
+ return s.replace(/(]*>)(<\/span>)/g, '$1$2')
- }
-
str = removeMustache(str).trimEnd()
const highlighted = highlighter.codeToHtml(str, {
@@ -164,6 +160,29 @@ 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' &&
+ span.children.length === 0
+ ) {
+ span.children.push({
+ type: 'element',
+ tagName: 'wbr',
+ properties: {},
+ children: []
+ })
+ }
+ })
+ }
+ })
+ }
+ },
...userTransformers
],
meta: { __raw: attrs },
@@ -172,6 +191,6 @@ export async function highlight(
: { theme })
})
- return fillEmptyLines(restoreMustache(highlighted))
+ return restoreMustache(highlighted)
}
}
From 176c4008c58a7b3beea8eebd699a930a7c17f9a1 Mon Sep 17 00:00:00 2001
From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Date: Sun, 31 Dec 2023 13:16:16 +0530
Subject: [PATCH 5/6] refactor: make conditions more robust
---
src/node/markdown/plugins/highlight.ts | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/node/markdown/plugins/highlight.ts b/src/node/markdown/plugins/highlight.ts
index 1ac99372..8f563cec 100644
--- a/src/node/markdown/plugins/highlight.ts
+++ b/src/node/markdown/plugins/highlight.ts
@@ -169,6 +169,8 @@ export async function highlight(
if (
span.type === 'element' &&
span.tagName === 'span' &&
+ Array.isArray(span.properties.class) &&
+ span.properties.class.includes('line') &&
span.children.length === 0
) {
span.children.push({
From 09e48db355f530c7a138437004659b61239f4b75 Mon Sep 17 00:00:00 2001
From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Date: Sun, 31 Dec 2023 13:35:04 +0530
Subject: [PATCH 6/6] feat: allow passing options to emoji plugin
close #3174
---
src/node/markdown/markdown.ts | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts
index f1ccb14d..5b6978c5 100644
--- a/src/node/markdown/markdown.ts
+++ b/src/node/markdown/markdown.ts
@@ -127,6 +127,15 @@ export interface MarkdownOptions extends MarkdownIt.Options {
allowedAttributes?: Array
disable?: boolean
}
+ /**
+ * Options for `markdown-it-emoji`
+ * @see https://github.com/markdown-it/markdown-it-emoji
+ */
+ emoji?: {
+ defs?: Record
+ enabled?: string[]
+ shortcuts?: Record
+ }
/**
* 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, {