From 882e686a442185cc1b5870c24f6ef09b77ba6cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=A0=91=E6=A0=91?= Date: Thu, 28 Aug 2025 14:53:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E6=94=AF=E6=8C=81=E5=B9=B6=E6=B8=85=E7=90=86?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除多语言i18n实现及相关翻译文件,简化代码结构 删除分类功能及相关组件和页面 将硬编码的中文文本直接替换原有国际化调用 清理不再使用的常量和工具函数 --- frontmatter.json | 5 --- scripts/new-post.js | 2 +- src/components/ArchivePanel.astro | 17 ++------ src/components/LightDarkSwitch.svelte | 9 ++--- src/components/PostCard.astro | 11 ++--- src/components/PostMeta.astro | 22 +--------- src/components/PostPage.astro | 1 - src/components/Search.svelte | 5 +-- src/components/misc/License.astro | 9 ++--- src/components/widget/Categories.astro | 37 ----------------- src/components/widget/DisplaySettings.svelte | 7 ++-- src/components/widget/SideBar.astro | 4 +- src/components/widget/Tags.astro | 5 +-- src/components/widget/WidgetLayout.astro | 5 +-- src/constants/link-presets.ts | 9 ++--- src/content/config.ts | 1 - src/i18n/i18nKey.ts | 37 ----------------- src/i18n/languages/en.ts | 38 ------------------ src/i18n/languages/es.ts | 38 ------------------ src/i18n/languages/ja.ts | 38 ------------------ src/i18n/languages/ko.ts | 38 ------------------ src/i18n/languages/th.ts | 38 ------------------ src/i18n/languages/zh_CN.ts | 38 ------------------ src/i18n/languages/zh_TW.ts | 38 ------------------ src/i18n/translation.ts | 40 ------------------- src/pages/about.astro | 5 +-- src/pages/archive/category/[category].astro | 24 ----------- .../archive/category/uncategorized.astro | 11 ----- src/pages/archive/index.astro | 5 +-- src/pages/archive/tag/[tag].astro | 5 +-- src/pages/posts/[...slug].astro | 8 ++-- src/types/config.ts | 1 - src/utils/content-utils.ts | 35 +--------------- src/utils/url-utils.ts | 9 +---- 34 files changed, 45 insertions(+), 550 deletions(-) delete mode 100644 src/components/widget/Categories.astro delete mode 100644 src/i18n/i18nKey.ts delete mode 100644 src/i18n/languages/en.ts delete mode 100644 src/i18n/languages/es.ts delete mode 100644 src/i18n/languages/ja.ts delete mode 100644 src/i18n/languages/ko.ts delete mode 100644 src/i18n/languages/th.ts delete mode 100644 src/i18n/languages/zh_CN.ts delete mode 100644 src/i18n/languages/zh_TW.ts delete mode 100644 src/i18n/translation.ts delete mode 100644 src/pages/archive/category/[category].astro delete mode 100644 src/pages/archive/category/uncategorized.astro diff --git a/frontmatter.json b/frontmatter.json index a377ad99e..ac17e0af8 100644 --- a/frontmatter.json +++ b/frontmatter.json @@ -46,11 +46,6 @@ "name": "tags", "type": "list" }, - { - "title": "category", - "name": "category", - "type": "string" - }, { "title": "draft", "name": "draft", diff --git a/scripts/new-post.js b/scripts/new-post.js index 187bfd0e7..9e99e7dc4 100644 --- a/scripts/new-post.js +++ b/scripts/new-post.js @@ -51,7 +51,7 @@ published: ${getDate()} description: '' image: '' tags: [] -category: '' + draft: false lang: '' --- diff --git a/src/components/ArchivePanel.astro b/src/components/ArchivePanel.astro index 24159c8c5..0fb37d498 100644 --- a/src/components/ArchivePanel.astro +++ b/src/components/ArchivePanel.astro @@ -1,16 +1,13 @@ --- -import { UNCATEGORIZED } from "@constants/constants"; -import I18nKey from "../i18n/i18nKey"; -import { i18n } from "../i18n/translation"; + import { getSortedPosts } from "../utils/content-utils"; import { getPostUrlBySlug } from "../utils/url-utils"; interface Props { keyword?: string; tags?: string[]; - categories?: string[]; } -const { tags, categories } = Astro.props; +const { tags } = Astro.props; let posts = await getSortedPosts(); @@ -22,13 +19,7 @@ if (Array.isArray(tags) && tags.length > 0) { ); } -if (Array.isArray(categories) && categories.length > 0) { - posts = posts.filter( - (post) => - (post.data.category && categories.includes(post.data.category)) || - (!post.data.category && categories.includes(UNCATEGORIZED)), - ); -} + const groups: { year: number; posts: typeof posts }[] = (() => { const groupedPosts = posts.reduce( @@ -74,7 +65,7 @@ function formatTag(tag: string[]) {
-
{group.posts.length} {i18n(I18nKey.postsCount)}
+
{group.posts.length} 篇文章
{group.posts.map(post => ( import type { LIGHT_DARK_MODE } from "@/types/config.ts"; import { AUTO_MODE, DARK_MODE, LIGHT_MODE } from "@constants/constants.ts"; -import I18nKey from "@i18n/i18nKey"; -import { i18n } from "@i18n/translation"; + import Icon from "@iconify/svelte"; import { applyThemeToDocument, @@ -78,21 +77,21 @@ function hidePanel() { onclick={() => switchScheme(LIGHT_MODE)} > - {i18n(I18nKey.lightMode)} + 浅色模式 diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index 56ed8c046..fdcfa053e 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -2,8 +2,7 @@ import path from "node:path"; import type { CollectionEntry } from "astro:content"; import { Icon } from "astro-icon/components"; -import I18nKey from "../i18n/i18nKey"; -import { i18n } from "../i18n/translation"; + import { getDir } from "../utils/url-utils"; import PostMetadata from "./PostMeta.astro"; import ImageWrapper from "./misc/ImageWrapper.astro"; @@ -17,7 +16,6 @@ interface Props { published: Date; updated?: Date; tags: string[]; - category: string; image: string; description: string; draft: boolean; @@ -30,7 +28,6 @@ const { published, updated, tags, - category, image, description, style, @@ -65,7 +62,7 @@ const { remarkPluginFrontmatter } = await entry.render(); - +
@@ -74,9 +71,9 @@ const { remarkPluginFrontmatter } = await entry.render();
-
{remarkPluginFrontmatter.words} {" " + i18n(I18nKey.wordsCount)}
+
{remarkPluginFrontmatter.words} 字
|
-
{remarkPluginFrontmatter.minutes} {" " + i18n(I18nKey.minutesCount)}
+
{remarkPluginFrontmatter.minutes} 分钟
|
加载中... diff --git a/src/components/PostMeta.astro b/src/components/PostMeta.astro index 2e8070e16..f785fd3bd 100644 --- a/src/components/PostMeta.astro +++ b/src/components/PostMeta.astro @@ -1,7 +1,6 @@ --- import { Icon } from "astro-icon/components"; -import I18nKey from "../i18n/i18nKey"; -import { i18n } from "../i18n/translation"; + import { getDir, url } from "../utils/url-utils"; import { formatDateToYYYYMMDD } from "../utils/date-utils"; import { umamiConfig } from "../config"; @@ -11,7 +10,6 @@ interface Props { published: Date; updated?: Date; tags: string[]; - category: string; hideTagsForMobile?: boolean; hideUpdateDate?: boolean; slug?: string; @@ -20,7 +18,6 @@ const { published, updated, tags, - category, hideTagsForMobile = false, hideUpdateDate = false, slug, @@ -49,21 +46,6 @@ const className = Astro.props.class;
)} - - -
))} - {!(tags && tags.length > 0) &&
{i18n(I18nKey.noTags)}
} + {!(tags && tags.length > 0) &&
无标签
}
diff --git a/src/components/PostPage.astro b/src/components/PostPage.astro index 4e46ed462..4fdf8c8d8 100644 --- a/src/components/PostPage.astro +++ b/src/components/PostPage.astro @@ -14,7 +14,6 @@ const interval = 50; entry={entry} title={entry.data.title} tags={entry.data.tags} - category={entry.data.category} published={entry.data.published} updated={entry.data.updated} url={getPostUrlBySlug(entry.slug)} diff --git a/src/components/Search.svelte b/src/components/Search.svelte index 701b5df3e..e3e2214c3 100644 --- a/src/components/Search.svelte +++ b/src/components/Search.svelte @@ -1,6 +1,5 @@