From 7c2f070d36616df1f55b3a41d6a65190fd7e4bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E5=86=9C=E5=B0=8F=E6=98=93?= <237972113@qq.com> Date: Thu, 7 Mar 2024 13:30:08 +0800 Subject: [PATCH 1/6] fix: createContentLoader issue by changing pattern mapping from config.root to config.srcDir. (#3622) --- src/node/contentLoader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/contentLoader.ts b/src/node/contentLoader.ts index c213f794..5e4f4565 100644 --- a/src/node/contentLoader.ts +++ b/src/node/contentLoader.ts @@ -98,7 +98,7 @@ export function createContentLoader( } if (typeof pattern === 'string') pattern = [pattern] - pattern = pattern.map((p) => normalizePath(path.join(config.root, p))) + pattern = pattern.map((p) => normalizePath(path.join(config.srcDir, p))) let md: MarkdownRenderer From 3f6008d396c2e249afeb4aff99e39ecbb981a172 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:04:04 +0530 Subject: [PATCH 2/6] adjust comment --- src/node/contentLoader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/contentLoader.ts b/src/node/contentLoader.ts index 5e4f4565..dc8651ac 100644 --- a/src/node/contentLoader.ts +++ b/src/node/contentLoader.ts @@ -75,7 +75,7 @@ export interface ContentData { */ export function createContentLoader( /** - * files to glob / watch - relative to + * files to glob / watch - relative to srcDir */ pattern: string | string[], { From b2dff54dc97e3d4857423f037ba755285aeeca04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E5=86=9C=E5=B0=8F=E6=98=93?= <237972113@qq.com> Date: Thu, 7 Mar 2024 19:21:57 +0800 Subject: [PATCH 3/6] feat(build): add validation when initializing VitePress configuration --- src/node/init/init.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/node/init/init.ts b/src/node/init/init.ts index 774e528b..d8d1dd61 100644 --- a/src/node/init/init.ts +++ b/src/node/init/init.ts @@ -46,7 +46,14 @@ export async function init() { message: 'Where should VitePress initialize the config?', initialValue: './', validate(value) { - // TODO make sure directory is inside + const inputRoot = path.resolve(value) + const currentRoot = path.resolve() + if (!inputRoot.startsWith(currentRoot)) { + return 'Please make sure directory is inside' + } + if (fs.pathExistsSync(inputRoot)) { + return `${value} already exists` + } } }), From 8695c2731599c7fa0aeb3e1516edf55a0386ed3f Mon Sep 17 00:00:00 2001 From: Timothy Lau Date: Fri, 8 Mar 2024 17:07:58 +0800 Subject: [PATCH 4/6] fix: Fix directory validation logic and error message --- src/node/init/init.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/init/init.ts b/src/node/init/init.ts index d8d1dd61..1197c7f9 100644 --- a/src/node/init/init.ts +++ b/src/node/init/init.ts @@ -44,6 +44,7 @@ export async function init() { root: () => text({ message: 'Where should VitePress initialize the config?', + defaultValue: './', initialValue: './', validate(value) { const inputRoot = path.resolve(value) @@ -51,7 +52,7 @@ export async function init() { if (!inputRoot.startsWith(currentRoot)) { return 'Please make sure directory is inside' } - if (fs.pathExistsSync(inputRoot)) { + if (inputRoot != currentRoot && fs.pathExistsSync(inputRoot)) { return `${value} already exists` } } From ee7fa47f0a7b916e08c545fdc839a1a93d7b7b99 Mon Sep 17 00:00:00 2001 From: Timothy Lau Date: Wed, 17 Apr 2024 10:53:34 +0800 Subject: [PATCH 5/6] feat(default theme): Add icons on action buttons --- docs/index.md | 6 +++ docs/reference/default-theme-home-page.md | 17 +++++++ .../theme-default/components/VPButton.vue | 49 ++++++++++++++++++- .../theme-default/components/VPHero.vue | 4 ++ types/default-theme.d.ts | 16 ++++++ 5 files changed, 90 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 9be32c3e..3c7faece 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,12 +12,18 @@ hero: - theme: brand text: What is VitePress? link: /guide/what-is-vitepress + startIcon: + src: /public/vitepress-logo-mini.svg + width: 18 + height: 18 + endIcon: - theme: alt text: Quickstart link: /guide/getting-started - theme: alt text: GitHub link: https://github.com/vuejs/vitepress + endIcon: image: src: /vitepress-logo-large.webp alt: VitePress diff --git a/docs/reference/default-theme-home-page.md b/docs/reference/default-theme-home-page.md index f7baecca..3cf9fc96 100644 --- a/docs/reference/default-theme-home-page.md +++ b/docs/reference/default-theme-home-page.md @@ -75,7 +75,24 @@ interface HeroAction { // Link rel attribute. rel?: string + + // Show the left icon on action button. + startIcon?: ActionIcon + + // Show the right icon on action button. + endIcon?: ActionIcon } + +type ActionIcon = + | string + | { src: string; alt?: string; width?: string; height: string } + | { + light: string + dark: string + alt?: string + width?: string + height: string + } ``` ### Customizing the name color diff --git a/src/client/theme-default/components/VPButton.vue b/src/client/theme-default/components/VPButton.vue index 3b9152f2..55d63209 100644 --- a/src/client/theme-default/components/VPButton.vue +++ b/src/client/theme-default/components/VPButton.vue @@ -1,7 +1,9 @@