From ccbfc16db5bdcc53c3dd9c6ba6f1d77a202ef0d9 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Tue, 3 Sep 2024 11:17:22 +0800 Subject: [PATCH 1/6] chore: remove unnecessary code --- cli/src/prompt.ts | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/cli/src/prompt.ts b/cli/src/prompt.ts index 020c1c21..7d048ea4 100644 --- a/cli/src/prompt.ts +++ b/cli/src/prompt.ts @@ -1,5 +1,4 @@ import process from 'node:process' -import path from 'node:path' import { createRequire } from 'node:module' import { cancel, confirm, group, select, text } from '@clack/prompts' import { setLang, t } from './translate.js' @@ -132,34 +131,3 @@ export async function prompt(mode: Mode, root?: string): Promise { return result } - -export async function getTargetDir(cwd: string, dir?: string) { - if (dir === '.') - return cwd - - if (typeof dir === 'string' && dir) { - return path.resolve(cwd, dir) - } - - const DEFAULT_DIR = 'my-project' - - const dirPath = await text({ - message: t('question.root'), - placeholder: DEFAULT_DIR, - validate(value) { - if (value && REG_DIR_CHAR.test(value)) - return t('hint.root.illegal') - - return undefined - }, - defaultValue: DEFAULT_DIR, - }) - - if (typeof dirPath === 'string') { - if (dirPath === '.') - return cwd - - return path.join(cwd, dirPath || DEFAULT_DIR) - } - return dirPath -} From f60e4ea63ec8c65b6ae03f7be29522ec5a79e68c Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Tue, 3 Sep 2024 11:19:02 +0800 Subject: [PATCH 2/6] feat(theme): add support blog as home page --- theme/package.json | 4 ++-- theme/src/client/components/Blog/VPBlog.vue | 16 +++++++++++-- .../src/client/components/Blog/VPPostList.vue | 7 +++++- theme/src/client/components/Home/VPHome.vue | 23 ++++++++++++++++++- theme/src/client/components/VPContent.vue | 18 ++++++++++++++- .../src/client/composables/blog-post-list.ts | 14 ++++++++--- theme/src/client/utils/dom.ts | 12 ++++++++++ theme/src/client/utils/index.ts | 4 ++-- theme/src/node/config/resolveLocaleOptions.ts | 3 ++- theme/src/node/setupPages.ts | 15 ++++++++---- theme/src/shared/blog.ts | 20 ++++++++++------ theme/src/shared/frontmatter/normal.ts | 2 +- 12 files changed, 113 insertions(+), 25 deletions(-) diff --git a/theme/package.json b/theme/package.json index 383b5e26..9054b2aa 100644 --- a/theme/package.json +++ b/theme/package.json @@ -104,11 +104,11 @@ "local-pkg": "^0.5.0", "nanoid": "^5.0.7", "vue": "^3.4.38", - "vue-router": "^4.4.3", "vuepress-plugin-md-enhance": "2.0.0-rc.52", "vuepress-plugin-md-power": "workspace:*" }, "devDependencies": { - "@iconify/json": "^2.2.243" + "@iconify/json": "^2.2.243", + "vue-router": "^4.4.3" } } diff --git a/theme/src/client/components/Blog/VPBlog.vue b/theme/src/client/components/Blog/VPBlog.vue index 9ed725d4..e279dbc7 100644 --- a/theme/src/client/components/Blog/VPBlog.vue +++ b/theme/src/client/components/Blog/VPBlog.vue @@ -9,11 +9,17 @@ import VPBlogNav from '@theme/Blog/VPBlogNav.vue' import VPTransitionFadeSlideY from '@theme/VPTransitionFadeSlideY.vue' import { useData } from '../../composables/index.js' +defineProps<{ + homeBlog?: boolean + type?: string + onlyOnce?: boolean +}>() + const { theme, page } = useData() - + @@ -96,6 +102,12 @@ const { theme, page } = useData() transition: background-color var(--t-color); } +@media(min-width: 419px) { + .vp-blog.home-blog { + background-color: var(--vp-c-bg-alt); + } +} + .blog-container { display: flex; align-items: flex-start; diff --git a/theme/src/client/components/Blog/VPPostList.vue b/theme/src/client/components/Blog/VPPostList.vue index bb876238..45e3779e 100644 --- a/theme/src/client/components/Blog/VPPostList.vue +++ b/theme/src/client/components/Blog/VPPostList.vue @@ -1,9 +1,14 @@