◉ClassyGitShadowzzh

ModuleGrid.astro

ModuleGrid.astro
---
// src/components/home/ModuleGrid.astro
// 章节合并卡网格容器
import ModuleCard from '../ModuleCard.astro';
import { getPublishedModules, groupByChapter } from '../../utils/collection';

interface Props { book?: string; }
const { book } = Astro.props;

const all = await getPublishedModules(book);
const chapters = groupByChapter(all);
---

<section class="all-modules">
  <h2 class="section-title">全部章节</h2>
  <p class="section-note">每章都有 TypeScript 与 Python 两个版本;Python 版为转写,方便只熟悉 Python 的读者。</p>
  <div class="modules-grid">
    {chapters.map(ch => <ModuleCard chapter={ch} />)}
  </div>
</section>

<style>
.all-modules {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-4) var(--space-6) var(--space-24);
}
.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  text-align: center;
  margin: 0 0 var(--space-3);
  color: var(--ink-strong);
}
.section-note {
  text-align: center;
  font-size: var(--fs-small);
  line-height: var(--lh-prose);
  color: var(--muted);
  font-style: italic;
  margin: 0 0 var(--space-12);
}
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
}
</style>