|
| 1 | +--- |
| 2 | +import StarlightPage, { |
| 3 | + type StarlightPageProps, |
| 4 | +} from "@astrojs/starlight/components/StarlightPage.astro"; |
| 5 | +import Pagination from "@astrojs/starlight/components/Pagination.astro"; |
| 6 | +
|
| 7 | +import type { GetStaticPaths } from "astro"; |
| 8 | +
|
| 9 | +import { format } from "date-fns"; |
| 10 | +import { getChangelogs } from "~/util/changelog"; |
| 11 | +import ProductPills from "~/components/changelog/ProductPills.astro"; |
| 12 | +
|
| 13 | +export const getStaticPaths = (async ({ paginate }) => { |
| 14 | + const notes = await getChangelogs({}); |
| 15 | +
|
| 16 | + return paginate(notes, { pageSize: 50 }); |
| 17 | +}) satisfies GetStaticPaths; |
| 18 | +
|
| 19 | +const { page } = Astro.props; |
| 20 | +
|
| 21 | +const prev = |
| 22 | + page.currentPage !== 1 |
| 23 | + ? { |
| 24 | + label: `Page ${page.currentPage - 1}`, |
| 25 | + link: `/changelog/historical/${page.currentPage - 1}/`, |
| 26 | + } |
| 27 | + : undefined; |
| 28 | +
|
| 29 | +const next = |
| 30 | + page.currentPage !== page.lastPage |
| 31 | + ? { |
| 32 | + label: `Page ${page.currentPage + 1}`, |
| 33 | + link: `/changelog/historical/${page.currentPage + 1}/`, |
| 34 | + } |
| 35 | + : undefined; |
| 36 | +
|
| 37 | +const props = { |
| 38 | + frontmatter: { |
| 39 | + title: "Historical changelogs", |
| 40 | + tableOfContents: false, |
| 41 | + template: "splash", |
| 42 | + chatbot_deprioritize: true, |
| 43 | + prev, |
| 44 | + next, |
| 45 | + }, |
| 46 | + hideBreadcrumbs: true, |
| 47 | +} as StarlightPageProps; |
| 48 | +--- |
| 49 | + |
| 50 | +<StarlightPage {...props}> |
| 51 | + { |
| 52 | + page.data.map((note) => { |
| 53 | + return ( |
| 54 | + <div> |
| 55 | + <h3>{note.data.title}</h3> |
| 56 | + <time class="font-bold" datetime={note.data.date.toISOString()}> |
| 57 | + {format(note.data.date, "MMM dd, yyyy")} |
| 58 | + </time> |
| 59 | + <ProductPills products={note.data.products} /> |
| 60 | + <p>{note.data.description}</p> |
| 61 | + <a href={`/changelog/${note.id}/`}>Read more</a> |
| 62 | + </div> |
| 63 | + ); |
| 64 | + }) |
| 65 | + } |
| 66 | + <Pagination /> |
| 67 | +</StarlightPage> |
0 commit comments