Refactor blog structure and update navigation

- 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 <noreply@anthropic.com>
This commit is contained in:
Clas Wen 2025-09-27 16:12:01 +08:00
parent a830ba1743
commit c8eb20e13f
6 changed files with 18 additions and 15 deletions

View file

@ -8,7 +8,7 @@ export default function App() {
const menuItems = [ const menuItems = [
{ {
link: "/archive", link: "/blog",
name: "博客", name: "博客",
}, },
{ {

View file

@ -3,3 +3,5 @@ export const SITE_EMAIL = "contact@nbtca.space"
export const SITE_NAME = "NingboTech University, Computer Association" export const SITE_NAME = "NingboTech University, Computer Association"
export const SITE_DESCRIPTION = "Computer Association" export const SITE_DESCRIPTION = "Computer Association"
export const SITE_URL = import.meta.env.PUBLIC_SITE_URL 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"

View file

@ -1,10 +1,11 @@
--- ---
import { CA_LOGO_URL } from "../consts"
import { formatDate } from "../utils" import { formatDate } from "../utils"
const { title, href, cover, tags, date } = Astro.props const { title, href, cover, tags, date } = Astro.props
const dateFormatted = formatDate(date) const dateFormatted = formatDate(date)
const type = tags?.[0] ?? "默认" 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}`; const label = `${title} - ${type} - 发表时间 ${dateFormatted}`;
--- ---

View file

@ -2,6 +2,7 @@
import BaseLayout from "../layouts/BaseLayout.astro" import BaseLayout from "../layouts/BaseLayout.astro"
import type { MarkdownInstance } from "astro" import type { MarkdownInstance } from "astro"
import dayjs from "dayjs" import dayjs from "dayjs"
import { CA_LOGO_URL } from "../consts"
type Cover = { type Cover = {
url: string url: string
@ -61,21 +62,19 @@ const getCover = (post: MarkdownInstance<Post>) => {
allPosts.map((v) => { allPosts.map((v) => {
return ( return (
<a class="flex items-start sm:items-center gap-4 sm:gap-6 py-8 no-underline appearance-none text-gray-900 cursor-pointer" style="text-decoration:none" href={v.url}> <a class="flex items-start sm:items-center gap-4 sm:gap-6 py-8 no-underline appearance-none text-gray-900 cursor-pointer" style="text-decoration:none" href={v.url}>
<div class=""> <img
<img class="rounded-xl sm:rounded-[20px] w-[105px] sm:w-[264px] xl:w-[295px] shrink-0 aspect-video overflow-hidden bg-gray-100 object-cover object-center archive-cover"
class="rounded-xl sm:rounded-[20px] w-[105px] sm:w-[264px] xl:w-[295px] aspect-video overflow-hidden bg-gray-100 object-cover object-center archive-cover" src={getCover(v).url || CA_LOGO_URL}
src={getCover(v).url} alt={getCover(v).alt || "fallback cover"}
alt={getCover(v).alt} />
/> <div class="flex flex-col gap-1 sm:gap-2">
</div>
<div class="flex flex-col gap-2">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
{v.frontmatter.tags.map((tag) => { {v.frontmatter.tags.slice(0, 3).map((tag) => {
return <span class="text-xs text-gray-700">{tag}</span> return <span class="text-xs text-gray-700">{tag}</span>
})} })}
</div> </div>
<div class="sm:text-xl font-bold">{v.frontmatter.title}</div> <div class="sm:text-xl font-bold">{v.frontmatter.title}</div>
<div class="text-sm font-semibold text-gray-600 sm:mt-1">{dayjs(v.frontmatter.pubDate).format("YYYY-MM-DD")}</div> <div class="text-sm sm:font-semibold text-gray-600 sm:mt-1">{dayjs(v.frontmatter.pubDate).format("YYYY-MM-DD")}</div>
</div> </div>
</a> </a>
<div class="w-full h-[0.5px] bg-gray-600 my-1 flex-shrink-0 last:hidden"></div> <div class="w-full h-[0.5px] bg-gray-600 my-1 flex-shrink-0 last:hidden"></div>

View file

@ -5,6 +5,7 @@ import { Alert, Button, Calendar, Link, Spinner, Select, SelectItem } from "@her
import { today, getLocalTimeZone } from "@internationalized/date" import { today, getLocalTimeZone } from "@internationalized/date"
import "dayjs/locale/zh-cn" import "dayjs/locale/zh-cn"
import { CA_PUBLIC_ICAL_URL } from "../../consts"
dayjs.locale("zh-cn") dayjs.locale("zh-cn")
@ -17,7 +18,7 @@ type ScheduleEvent = {
} }
const parseCal = async (): Promise<ICAL.Component> => { const parseCal = async (): Promise<ICAL.Component> => {
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) const jcalData = ICAL.parse(res)
return new ICAL.Component(jcalData) return new ICAL.Component(jcalData)
} }

View file

@ -110,10 +110,10 @@ Blogs.sort(
</ul> </ul>
<div class="view-archive-wrapper"> <div class="view-archive-wrapper">
<a <a
href="/archive" href="/blog"
class="cta-primary-light" class="cta-primary-light"
data-analytics-region="router" data-analytics-region="router"
data-analytics-title="view archive" data-analytics-title="view blog"
> >
阅读历史文章 阅读历史文章
</a> </a>