--- export const prerender = true; import { getCollection } from "astro:content"; import { SITE } from "../site.config"; // 班史列表:src/content/*.md // 按时间倒序展示(最新在前);序号仍是时间正序的第 N 篇,与文章页一致 const posts = (await getCollection("chronicle")).sort( (a, b) => a.data.date.valueOf() - b.data.date.valueOf(), ); const pad = (n: number) => String(n).padStart(2, "0"); const total = posts.length; const items = posts .map((post, i) => { const d = post.data.date; return { index: i + 1, dateLabel: `${d.getFullYear()} · ${pad(d.getMonth() + 1)} · ${pad(d.getDate())}`, title: post.data.title, summary: post.data.summary, author: post.data.author, url: `/pages/${post.id.split("/").pop()}`, }; }) .reverse(); --- 班史列表 · {SITE.className}
← 返回班史 {SITE.className} · 班史列表 📝 投稿

班史列表

从初见的那一天起,每一段日子都有了名字 · 共 {total} 篇

{ items.length > 0 ? (
    {items.map((p) => (
  1. {String(p.index).padStart(2, "0")}
    {p.dateLabel}
    {p.title}
    {p.summary && (
    {p.summary}
    )} {p.author && (
    {p.author}
    )}
    查看 →
  2. ))}
) : (

班史还是空的,快去投稿吧~

) }