Marketing sectionsPostGrid
Searchastronomic.dev# PostGrid
To show the latest posts as cards, each with a picture, a date and a short excerpt.
Static: no JavaScript.
## Usage
```astro
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
```
## Examples
### Latest posts
Three posts as cards, each with a picture, the meta line (the topic, the date and the reading time), the title, an excerpt and a footer with the author, then the link to all posts. As many columns as fit, each at least 18rem: one on a phone, two from about 37rem, three in a wide row. Each card fills its row, so the footers line up on the bottom edge. The whole card opens the post; the topic is a link of its own.
```astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
// Your own pictures, and the authors' photos (Sam has none yet: his initials show).
import ada from "../../photos/portrait-curly-hair.webp";
import lena from "../../photos/portrait-glasses.webp";
import desk from "../../photos/studio-desk.webp";
import folders from "../../photos/folder-stack.webp";
import sketch from "../../photos/sketching-wireframes.webp";
// Newest first. Dates are "YYYY-MM-DD" strings, never new Date(...): see the date note in the props.
const posts = [
{
href: "#launch-checklist",
title: "A launch checklist for a small studio site",
date: "2026-10-14",
readingTime: "6 min read",
excerpt: "The twelve checks we run the week before a site goes live, from redirects and page titles to the contact form and the 404 page.",
image: { src: desk },
topic: { label: "Process", href: "#topic-process" },
author: { name: "Ada Brook", image: { src: ada } },
},
{
href: "#sketch-first",
title: "Sketch the page before the first pixel",
date: "2026-10-02",
readingTime: "4 min read",
excerpt: "Why every Astronomic project starts with a pencil, and what the sketches settle before the design begins.",
image: { src: sketch },
topic: { label: "Design", href: "#topic-design" },
author: { name: "Lena Ruiz", image: { src: lena } },
},
{
href: "#content-move",
title: "Moving an old site's content without losing a page",
date: "2026-09-18",
readingTime: "8 min read",
excerpt: "A spreadsheet, a redirect map and one rule: every old address still leads somewhere useful on the day the new site opens.",
image: { src: folders },
topic: { label: "Content", href: "#topic-content" },
author: { name: "Sam Okafor" },
},
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<PostGrid heading="Notes from the studio" text="How we plan, design and build sites, written up as we go." items={posts} viewAll={{ label: "All posts", href: "#blog" }} />
</div>
```
### No posts yet
No posts and an empty text: the heading, then the text in place of the list. With no empty text, no list and no text show: leave the section out.
```astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
// No posts yet: the empty text shows in place of the list.
---
<div class="mx-auto max-w-6xl px-6 py-16">
<PostGrid heading="Notes from the studio" items={[]} empty="No posts yet. The first one is on its way." />
</div>
```
### In a narrow column
Three posts in a 24rem column, one per row: one with a picture, one with no picture (the card starts with the meta line: its plain-text topic and the date), and one with no excerpt (the title, then the footer). A long title wraps inside the card.
```astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
import { displayType } from "@astronomic-dev/ui/lib/display.ts";
import plants from "../../photos/plants-shelf.webp";
const posts = [
{
href: "#accessibility-audit",
title: "What an accessibility audit of a twelve-page site actually finds",
date: "2026-10-07",
excerpt: "Contrast, headings and link names make up most of it. Here is what we fix first, and how long each fix takes.",
image: { src: plants },
topic: { label: "Accessibility", href: "#topic-accessibility" },
author: { name: "Tomás Vidal" },
},
// No picture: the card starts with the meta line (the topic, plain text here, and the date). No author: no footer.
{ href: "#hosting", title: "Where we host a client site, and why", date: "2026-09-21", excerpt: "Static files on a fast host, a form service, and nothing to patch at night.", topic: { label: "Build" } },
// No excerpt: the title, then the footer.
{ href: "#studio-news", title: "Tomás Vidal joins Astronomic", date: "2026-09-02", topic: { label: "News" }, author: { name: "Ada Brook" } },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<div data-narrow class="grid max-w-sm gap-blocks">
<h2 class={`m-0 text-title text-balance ${displayType}`}>In a narrow column</h2>
<PostGrid items={posts} />
</div>
</div>
```
### Your own images
Astro's <Image> draws each post's picture (imageComponent={Image}), with no wrapper; the kit draws the frame and passes a sizes hint for this layout; the authors' Avatars stay plain. Astro writes a srcset when your astro.config sets image.layout. For EmDash or another CMS, see "Your own images" in the kit README.
```astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
// Astro's <Image> draws each post's picture, with no wrapper; PostGrid passes it a sizes hint for its columns. The authors' Avatars stay plain.
// For a srcset, set image: { layout: "constrained" } in your astro.config.
import { Image } from "astro:assets";
// Your own pictures, and the authors' photos (Sam has none yet: his initials show).
import ada from "../../photos/portrait-curly-hair.webp";
import lena from "../../photos/portrait-glasses.webp";
import desk from "../../photos/studio-desk.webp";
import folders from "../../photos/folder-stack.webp";
import sketch from "../../photos/sketching-wireframes.webp";
// Newest first. Dates are "YYYY-MM-DD" strings, never new Date(...): see the date note in the props.
const posts = [
{
href: "#launch-checklist",
title: "A launch checklist for a small studio site",
date: "2026-10-14",
readingTime: "6 min read",
excerpt: "The twelve checks we run the week before a site goes live, from redirects and page titles to the contact form and the 404 page.",
image: { src: desk },
topic: { label: "Process", href: "#topic-process" },
author: { name: "Ada Brook", image: { src: ada } },
},
{
href: "#sketch-first",
title: "Sketch the page before the first pixel",
date: "2026-10-02",
readingTime: "4 min read",
excerpt: "Why every Astronomic project starts with a pencil, and what the sketches settle before the design begins.",
image: { src: sketch },
topic: { label: "Design", href: "#topic-design" },
author: { name: "Lena Ruiz", image: { src: lena } },
},
{
href: "#content-move",
title: "Moving an old site's content without losing a page",
date: "2026-09-18",
readingTime: "8 min read",
excerpt: "A spreadsheet, a redirect map and one rule: every old address still leads somewhere useful on the day the new site opens.",
image: { src: folders },
topic: { label: "Content", href: "#topic-content" },
author: { name: "Sam Okafor" },
},
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<PostGrid heading="Notes from the studio" text="How we plan, design and build sites, written up as we go." items={posts} viewAll={{ label: "All posts", href: "#blog" }} imageComponent={Image} />
</div>
```
## Props
### PostGrid
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | The section heading, in the title role in display type. Without it there is no section and no header: a plain <div> holds only the posts. |
| `emphasis` | `boolean` | `false` | Turn one *phrase* in the heading into <em>: exactly two asterisks around text with no space inside, as in "Built for *the long run*". Any other asterisks show as typed. Off by default, so the heading shows as typed. How the <em> looks is the theme's. |
| `mark` | `string` | None | A short mark after the heading, such as "(12)" or "©2026", in small muted type. It sits beside the heading, outside it, so the heading's name stays plain. Shown only with a heading. |
| `markLabel` | `string` | None | What the mark says to a screen reader, such as "12 projects": the mark is then hidden from screen readers and this is read in its place. Without it, the mark is read as written. |
| `text` | `string` | None | One or two sentences under the heading, in the lead role, muted. Shown only with a heading. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The heading element. Each post title sits one level under it. |
| `viewAll` | `PostsLink` | None | A link after the list: { label, href } (PostsLink), such as { label: "All posts", href: "/blog" }. Name the page, not "More". |
| `empty` | `string` | None | Text shown in place of the list when there are no posts, such as "No posts yet.". Without it, no posts render no list and no text. |
| `class` | `string` | None | More classes for the root (the <section>, or the <div> without a heading), merged with cn(), so yours win on conflicts. The root is a named size container (inline-size containment): in a shrink-to-fit parent (inline-flex, a float, fit-content) it collapses, so give it a width there. |
| `itemHeadingTag` | `"h2" \| "h3" \| "h4" \| "h5"` | `"h3"` | The title element when there is no heading. With a heading, titles sit one level under it. |
| `items` | `PostItem[]` | None | Required. The posts, newest first (the order you pass): { href, title, date?, dateLabel?, excerpt?, image?, topic?, author?, readingTime? } (PostItem). date (optional) is "YYYY-MM-DD", such as "2026-10-14" (the canonical form), or a Date read in UTC, as Astro content collections give. new Date(2026, 9, 14) is local midnight, which shows the day before east of UTC: pass the string instead. A bad value throws at build time with the value in the message, so no page says "Invalid Date". dateLabel is your own text in place of the printed date ("Updated 3 days ago"); the datetime stays the date, and it shows only with a date. image is { src, width?, height?, ratio?, focalPoint?, loading? }, with no alt: the part writes alt="", since the title says what the post is. topic is { label, href? }; author is { name, image? }; readingTime is your own text, such as "5 min read". Only these fields reach each post, so a CMS entry's other fields never reach the page. With none, the empty text shows, or nothing. |
| `locale` | `string` | `"en"` | The dates' language, such as "de" (14.10.2026); the default prints "Oct 14, 2026". Passed to every post (formatDate in lib/date.ts). The dates are read in UTC, so the day never moves with the time zone. |
| `imageComponent` | `ImageComponent` | None | Your image component, for every photo: Astro's <Image>, or a small wrapper for your CMS. The recipe passes a sizes hint for its columns, for the number of items (one: (min-width: 80rem) 77rem, 100vw; two: (min-width: 80rem) 38rem, (min-width: 40rem) 50vw, 100vw; three or more: (min-width: 80rem) 25rem, (min-width: 60rem) 33vw, (min-width: 40rem) 50vw, 100vw, gridImageSizes in lib/image.ts). See the own-images example and "Your own images" in the kit README. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. Shown only with a heading. |
Any other attribute goes on the <section>, or on the <div> without a heading.
## Accessibility
- With a heading, renders a <section> named by it, so it is a region landmark. The heading id is unique on the page.
- Without a heading, renders a plain <div>. Put your own heading above it.
- The posts are a list (<ul role="list">), so a screen reader says how many there are. Each post is an <article> in its <li>.
- Each title sits one level under the section heading (h2 gives h3), so a reader can jump from post to post. With no heading, it is an h3 unless you set itemHeadingTag.
- The title is the only link to the post, so a screen reader's list of links reads each title once, with no "Read more". On a card the whole card is clickable, and the title names it: the focus ring goes round the card.
- The topic is a link of its own to the topic's page. On a card it leads the meta line above the title, so Tab reaches it before the title; in a row it sits under the excerpt, so Tab reaches it after the title. Either way the Tab order is the reading order.
- The date is a <time> with a machine date (datetime="2026-10-14"), whatever the text says.
- With no posts the list is left out: the empty text shows in its place when you give one. With no posts and no empty text, leave the section out, or it is a heading over nothing.
- The view-all link comes after the posts. Name the page it opens ("All posts"), not "More". On touch screens it is a box of 44px at least.
PostGrid
FreeTo show the latest posts as cards, each with a picture, a date and a short excerpt.
- File
- PostGrid.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 4
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Latest posts
Three posts as cards, each with a picture, the meta line (the topic, the date and the reading time), the title, an excerpt and a footer with the author, then the link to all posts. As many columns as fit, each at least 18rem: one on a phone, two from about 37rem, three in a wide row. Each card fills its row, so the footers line up on the bottom edge. The whole card opens the post; the topic is a link of its own.
This preview did not load.
examples/postgrid/main.astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
// Your own pictures, and the authors' photos (Sam has none yet: his initials show).
import ada from "../../photos/portrait-curly-hair.webp";
import lena from "../../photos/portrait-glasses.webp";
import desk from "../../photos/studio-desk.webp";
import folders from "../../photos/folder-stack.webp";
import sketch from "../../photos/sketching-wireframes.webp";
// Newest first. Dates are "YYYY-MM-DD" strings, never new Date(...): see the date note in the props.
const posts = [
{
href: "#launch-checklist",
title: "A launch checklist for a small studio site",
date: "2026-10-14",
readingTime: "6 min read",
excerpt: "The twelve checks we run the week before a site goes live, from redirects and page titles to the contact form and the 404 page.",
image: { src: desk },
topic: { label: "Process", href: "#topic-process" },
author: { name: "Ada Brook", image: { src: ada } },
},
{
href: "#sketch-first",
title: "Sketch the page before the first pixel",
date: "2026-10-02",
readingTime: "4 min read",
excerpt: "Why every Astronomic project starts with a pencil, and what the sketches settle before the design begins.",
image: { src: sketch },
topic: { label: "Design", href: "#topic-design" },
author: { name: "Lena Ruiz", image: { src: lena } },
},
{
href: "#content-move",
title: "Moving an old site's content without losing a page",
date: "2026-09-18",
readingTime: "8 min read",
excerpt: "A spreadsheet, a redirect map and one rule: every old address still leads somewhere useful on the day the new site opens.",
image: { src: folders },
topic: { label: "Content", href: "#topic-content" },
author: { name: "Sam Okafor" },
},
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<PostGrid heading="Notes from the studio" text="How we plan, design and build sites, written up as we go." items={posts} viewAll={{ label: "All posts", href: "#blog" }} />
</div>No posts yet
No posts and an empty text: the heading, then the text in place of the list. With no empty text, no list and no text show: leave the section out.
This preview did not load.
examples/postgrid/empty.astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
// No posts yet: the empty text shows in place of the list.
---
<div class="mx-auto max-w-6xl px-6 py-16">
<PostGrid heading="Notes from the studio" items={[]} empty="No posts yet. The first one is on its way." />
</div>In a narrow column
Three posts in a 24rem column, one per row: one with a picture, one with no picture (the card starts with the meta line: its plain-text topic and the date), and one with no excerpt (the title, then the footer). A long title wraps inside the card.
This preview did not load.
examples/postgrid/narrow.astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
import { displayType } from "@astronomic-dev/ui/lib/display.ts";
import plants from "../../photos/plants-shelf.webp";
const posts = [
{
href: "#accessibility-audit",
title: "What an accessibility audit of a twelve-page site actually finds",
date: "2026-10-07",
excerpt: "Contrast, headings and link names make up most of it. Here is what we fix first, and how long each fix takes.",
image: { src: plants },
topic: { label: "Accessibility", href: "#topic-accessibility" },
author: { name: "Tomás Vidal" },
},
// No picture: the card starts with the meta line (the topic, plain text here, and the date). No author: no footer.
{ href: "#hosting", title: "Where we host a client site, and why", date: "2026-09-21", excerpt: "Static files on a fast host, a form service, and nothing to patch at night.", topic: { label: "Build" } },
// No excerpt: the title, then the footer.
{ href: "#studio-news", title: "Tomás Vidal joins Astronomic", date: "2026-09-02", topic: { label: "News" }, author: { name: "Ada Brook" } },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<div data-narrow class="grid max-w-sm gap-blocks">
<h2 class={`m-0 text-title text-balance ${displayType}`}>In a narrow column</h2>
<PostGrid items={posts} />
</div>
</div>Your own images
Astro's <Image> draws each post's picture (imageComponent={Image}), with no wrapper; the kit draws the frame and passes a sizes hint for this layout; the authors' Avatars stay plain. Astro writes a srcset when your astro.config sets image.layout. For EmDash or another CMS, see "Your own images" in the kit README.
This preview did not load.
examples/postgrid/own-images.astro
---
import PostGrid from "@astronomic-dev/ui/components/PostGrid.astro";
// Astro's <Image> draws each post's picture, with no wrapper; PostGrid passes it a sizes hint for its columns. The authors' Avatars stay plain.
// For a srcset, set image: { layout: "constrained" } in your astro.config.
import { Image } from "astro:assets";
// Your own pictures, and the authors' photos (Sam has none yet: his initials show).
import ada from "../../photos/portrait-curly-hair.webp";
import lena from "../../photos/portrait-glasses.webp";
import desk from "../../photos/studio-desk.webp";
import folders from "../../photos/folder-stack.webp";
import sketch from "../../photos/sketching-wireframes.webp";
// Newest first. Dates are "YYYY-MM-DD" strings, never new Date(...): see the date note in the props.
const posts = [
{
href: "#launch-checklist",
title: "A launch checklist for a small studio site",
date: "2026-10-14",
readingTime: "6 min read",
excerpt: "The twelve checks we run the week before a site goes live, from redirects and page titles to the contact form and the 404 page.",
image: { src: desk },
topic: { label: "Process", href: "#topic-process" },
author: { name: "Ada Brook", image: { src: ada } },
},
{
href: "#sketch-first",
title: "Sketch the page before the first pixel",
date: "2026-10-02",
readingTime: "4 min read",
excerpt: "Why every Astronomic project starts with a pencil, and what the sketches settle before the design begins.",
image: { src: sketch },
topic: { label: "Design", href: "#topic-design" },
author: { name: "Lena Ruiz", image: { src: lena } },
},
{
href: "#content-move",
title: "Moving an old site's content without losing a page",
date: "2026-09-18",
readingTime: "8 min read",
excerpt: "A spreadsheet, a redirect map and one rule: every old address still leads somewhere useful on the day the new site opens.",
image: { src: folders },
topic: { label: "Content", href: "#topic-content" },
author: { name: "Sam Okafor" },
},
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<PostGrid heading="Notes from the studio" text="How we plan, design and build sites, written up as we go." items={posts} viewAll={{ label: "All posts", href: "#blog" }} imageComponent={Image} />
</div>