---
import { getCollection } from "astro:content";
import BaseLayout from "../layouts/BaseLayout.astro";

const posts = await getCollection("posts");
const sites = await getCollection("sites");
const rows = [...posts, ...sites].sort((a, b) => b.data.date.localeCompare(a.data.date));
---

<BaseLayout title="公开研究索引" description="K1412 Research 的文章、实验报告与独立专题站索引。">
  <section class="archive-page">
    <header class="page-intro">
      <p class="eyebrow">ARCHIVE</p>
      <h1>公开研究索引</h1>
      <p>按发布日期记录文章与独立专题站。草稿保留在源码中，不进入公开索引。</p>
    </header>
    <div class="archive-table">
      {rows.filter((row) => row.data.status === "published").map((row) => (
        <a class="archive-row" href={row.data.canonicalUrl}>
          <time>{row.data.date}</time>
          <strong>{row.data.title}</strong>
          <span>{row.data.kind === "site" ? "独立专题" : "文章"}</span>
          <i aria-hidden="true">↗</i>
        </a>
      ))}
    </div>
  </section>
</BaseLayout>
