From d1e56f3e8c4574f46b07f707463d723cdad88d3e Mon Sep 17 00:00:00 2001 From: voson Date: Tue, 3 Feb 2026 16:33:39 +0800 Subject: [PATCH] feat: add ArticleCard component and update site content for Chinese localization --- .gitignore | 2 + src/components/ArticleCard.astro | 244 +++++++++++++++++++++++++++++ src/components/Footer.astro | 62 -------- src/components/FormattedDate.astro | 4 +- src/components/Header.astro | 25 --- src/consts.ts | 4 +- src/content/blog/first-post.md | 2 +- src/content/blog/third-post.md | 16 -- src/content/blog/using-mdx.mdx | 31 ---- src/layouts/BlogPost.astro | 4 +- src/layouts/SiteLayout.astro | 27 ---- src/pages/about.astro | 63 -------- src/pages/index.astro | 102 +++++++----- src/pages/search.astro | 43 ----- src/styles/global.css | 5 +- 15 files changed, 314 insertions(+), 320 deletions(-) create mode 100644 src/components/ArticleCard.astro delete mode 100644 src/components/Footer.astro delete mode 100644 src/content/blog/third-post.md delete mode 100644 src/content/blog/using-mdx.mdx delete mode 100644 src/layouts/SiteLayout.astro delete mode 100644 src/pages/about.astro delete mode 100644 src/pages/search.astro diff --git a/.gitignore b/.gitignore index 16d54bb..06c1e92 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ pnpm-debug.log* # jetbrains setting folder .idea/ + +*.obsidian/ \ No newline at end of file diff --git a/src/components/ArticleCard.astro b/src/components/ArticleCard.astro new file mode 100644 index 0000000..41ef4d2 --- /dev/null +++ b/src/components/ArticleCard.astro @@ -0,0 +1,244 @@ +--- +import FormattedDate from './FormattedDate.astro'; + +interface Props { + title: string; + description: string; + pubDate: Date; + slug: string; + readingTime: number; + featured?: boolean; +} + +const { title, description, pubDate, slug, readingTime, featured = false } = Astro.props; +const hasContent = Astro.slots.has('default'); +--- + +
+

+ {title} +

+ +

{description}

+ {featured && hasContent ? ( + <> +
+
+ +
+
+
+ + + ) : ( + 阅读更多 + )} +
+ +{featured && hasContent && ( + +)} + + diff --git a/src/components/Footer.astro b/src/components/Footer.astro deleted file mode 100644 index 96c2fce..0000000 --- a/src/components/Footer.astro +++ /dev/null @@ -1,62 +0,0 @@ ---- -const today = new Date(); ---- - - - diff --git a/src/components/FormattedDate.astro b/src/components/FormattedDate.astro index 1bcce73..558cc9b 100644 --- a/src/components/FormattedDate.astro +++ b/src/components/FormattedDate.astro @@ -8,9 +8,9 @@ const { date } = Astro.props;