From c8eb20e13f12d645a60d18ff5c6acbd121b38649 Mon Sep 17 00:00:00 2001 From: Clas Wen Date: Sat, 27 Sep 2025 16:12:01 +0800 Subject: [PATCH] Refactor blog structure and update navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace archive page with new blog page - Update navigation links from /archive to /blog - Extract CA logo and iCal URLs to constants - Update references throughout codebase to use new constants 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/components/header/HeaderNavigation.tsx | 2 +- src/consts.ts | 2 ++ src/layouts/MoreTile.astro | 3 ++- src/pages/{archive.astro => blog.astro} | 19 +++++++++---------- src/pages/calendar/Schedule.tsx | 3 ++- src/pages/index.astro | 4 ++-- 6 files changed, 18 insertions(+), 15 deletions(-) rename src/pages/{archive.astro => blog.astro} (79%) diff --git a/src/components/header/HeaderNavigation.tsx b/src/components/header/HeaderNavigation.tsx index 4733422..d896dca 100644 --- a/src/components/header/HeaderNavigation.tsx +++ b/src/components/header/HeaderNavigation.tsx @@ -8,7 +8,7 @@ export default function App() { const menuItems = [ { - link: "/archive", + link: "/blog", name: "博客", }, { diff --git a/src/consts.ts b/src/consts.ts index 3335637..04572f1 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -3,3 +3,5 @@ export const SITE_EMAIL = "contact@nbtca.space" export const SITE_NAME = "NingboTech University, Computer Association" export const SITE_DESCRIPTION = "Computer Association" export const SITE_URL = import.meta.env.PUBLIC_SITE_URL +export const CA_LOGO_URL = "https://oss.nbtca.space/CA-logo.svg" +export const CA_PUBLIC_ICAL_URL = "https://ical.nbtca.space" diff --git a/src/layouts/MoreTile.astro b/src/layouts/MoreTile.astro index a09fe01..d166571 100644 --- a/src/layouts/MoreTile.astro +++ b/src/layouts/MoreTile.astro @@ -1,10 +1,11 @@ --- +import { CA_LOGO_URL } from "../consts" import { formatDate } from "../utils" const { title, href, cover, tags, date } = Astro.props const dateFormatted = formatDate(date) const type = tags?.[0] ?? "默认" -const image = cover?.url ?? cover ?? "https://oss.nbtca.space/CA-logo.svg" +const image = cover?.url ?? cover ?? CA_LOGO_URL const label = `${title} - ${type} - 发表时间 ${dateFormatted}`; --- diff --git a/src/pages/archive.astro b/src/pages/blog.astro similarity index 79% rename from src/pages/archive.astro rename to src/pages/blog.astro index e598d7c..b894a80 100644 --- a/src/pages/archive.astro +++ b/src/pages/blog.astro @@ -2,6 +2,7 @@ import BaseLayout from "../layouts/BaseLayout.astro" import type { MarkdownInstance } from "astro" import dayjs from "dayjs" +import { CA_LOGO_URL } from "../consts" type Cover = { url: string @@ -61,21 +62,19 @@ const getCover = (post: MarkdownInstance) => { allPosts.map((v) => { return ( -
- {getCover(v).alt} -
-
+ {getCover(v).alt +
- {v.frontmatter.tags.map((tag) => { + {v.frontmatter.tags.slice(0, 3).map((tag) => { return {tag} })}
{v.frontmatter.title}
-
{dayjs(v.frontmatter.pubDate).format("YYYY-MM-DD")}
+
{dayjs(v.frontmatter.pubDate).format("YYYY-MM-DD")}
diff --git a/src/pages/calendar/Schedule.tsx b/src/pages/calendar/Schedule.tsx index af70ec3..d869fe5 100644 --- a/src/pages/calendar/Schedule.tsx +++ b/src/pages/calendar/Schedule.tsx @@ -5,6 +5,7 @@ import { Alert, Button, Calendar, Link, Spinner, Select, SelectItem } from "@her import { today, getLocalTimeZone } from "@internationalized/date" import "dayjs/locale/zh-cn" +import { CA_PUBLIC_ICAL_URL } from "../../consts" dayjs.locale("zh-cn") @@ -17,7 +18,7 @@ type ScheduleEvent = { } const parseCal = async (): Promise => { - const res = await fetch("https://ical.nbtca.space/").then(res => res.text()) + const res = await fetch(CA_PUBLIC_ICAL_URL).then(res => res.text()) const jcalData = ICAL.parse(res) return new ICAL.Component(jcalData) } diff --git a/src/pages/index.astro b/src/pages/index.astro index 42697ad..541138a 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -110,10 +110,10 @@ Blogs.sort(