Marketing sectionsPosts
Searchastronomic.dev# Posts
To build your own blog list: a section heading and posts, each with a title, a date and a link. For a ready layout, use PostGrid or PostList.
Static: no JavaScript.
## Usage
```astro
import Posts from "@astronomic-dev/ui/components/Posts.astro";
```
## Examples
### Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then the list of posts in the default slot, one PostCard (or PostRow) in an <li> each, then the view-all link. The shell sets the type and the gaps; the recipes lay out the list. PostGrid and PostList are recipes built on it, and Pro adds PostFeatured and PostCompact. childHeadingTag() in lib/heading.ts gives the titles' heading level.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import PostCard from "@astronomic-dev/ui/components/PostCard.astro";
import Posts from "@astronomic-dev/ui/components/Posts.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
// Your own pictures.
import desk from "../../photos/studio-desk.webp";
import sketch from "../../photos/sketching-wireframes.webp";
const heading = "Notes from the studio";
// Dates are "YYYY-MM-DD" strings, newest first.
const posts = [
{
href: "#launch-checklist",
title: "A launch checklist for a small studio site",
date: "2026-10-14",
excerpt: "The twelve checks we run the week before a site goes live, from redirects to the contact form.",
image: { src: desk },
topic: { label: "Process", href: "#topic-process" },
author: { name: "Ada Brook" },
},
{
href: "#sketch-first",
title: "Sketch the page before the first pixel",
date: "2026-10-02",
excerpt: "Why every Astronomic project starts with a pencil, and what the sketches decide before design begins.",
image: { src: sketch },
topic: { label: "Design", href: "#topic-design" },
author: { name: "Lena Ruiz" },
},
];
// One level under the section heading: h2 gives h3.
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl px-6 py-16">
<Posts heading={heading} text="How we plan, design and build sites, written up as we go." viewAll={{ label: "All posts", href: "#blog" }} listClass="grid-cols-[repeat(auto-fit,minmax(min(100%,18rem),1fr))] gap-cards">
<Badge slot="eyebrow">Blog</Badge>
{
posts.map((p) => (
<li class="grid min-w-0">
<PostCard href={p.href} title={p.title} date={p.date} excerpt={p.excerpt} image={p.image} topic={p.topic} author={p.author} headingTag={tag} />
</li>
))
}
</Posts>
</div>
```
## Props
### Posts
| 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. |
| `align` | `"start" \| "center"` | `"start"` | For recipes. The alignment of the header (SectionHead) only: the recipe lays out the list. |
| `contentClass` | `string` | None | For recipes. Classes for the row that holds the header, the posts and the view-all link. |
| `headerClass` | `string` | None | For recipes. Classes for the header (the eyebrow, the heading and the text). |
| `listClass` | `string` | None | For recipes. Classes for the list of posts (the <ul>), such as its columns and gaps. It sits inside the posts container, so its classes can query it (@3xl/posts:...). |
| `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. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. Shown only with a heading. |
| `default` | The posts: one <li> each, holding a PostCard or a PostRow. Leave it empty for the empty text. |
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. Pass childHeadingTag({ heading, headingTag }) from lib/heading.ts to each PostCard's or PostRow's headingTag; with no heading it gives an h3.
- 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.
Posts
FreeTo build your own blog list: a section heading and posts, each with a title, a date and a link. For a ready layout, use PostGrid or PostList.
- File
- Posts.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then the list of posts in the default slot, one PostCard (or PostRow) in an <li> each, then the view-all link. The shell sets the type and the gaps; the recipes lay out the list. PostGrid and PostList are recipes built on it, and Pro adds PostFeatured and PostCompact. childHeadingTag() in lib/heading.ts gives the titles' heading level.
This preview did not load.
main.astro
examples/posts/main.astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import PostCard from "@astronomic-dev/ui/components/PostCard.astro";
import Posts from "@astronomic-dev/ui/components/Posts.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
// Your own pictures.
import desk from "../../photos/studio-desk.webp";
import sketch from "../../photos/sketching-wireframes.webp";
const heading = "Notes from the studio";
// Dates are "YYYY-MM-DD" strings, newest first.
const posts = [
{
href: "#launch-checklist",
title: "A launch checklist for a small studio site",
date: "2026-10-14",
excerpt: "The twelve checks we run the week before a site goes live, from redirects to the contact form.",
image: { src: desk },
topic: { label: "Process", href: "#topic-process" },
author: { name: "Ada Brook" },
},
{
href: "#sketch-first",
title: "Sketch the page before the first pixel",
date: "2026-10-02",
excerpt: "Why every Astronomic project starts with a pencil, and what the sketches decide before design begins.",
image: { src: sketch },
topic: { label: "Design", href: "#topic-design" },
author: { name: "Lena Ruiz" },
},
];
// One level under the section heading: h2 gives h3.
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl px-6 py-16">
<Posts heading={heading} text="How we plan, design and build sites, written up as we go." viewAll={{ label: "All posts", href: "#blog" }} listClass="grid-cols-[repeat(auto-fit,minmax(min(100%,18rem),1fr))] gap-cards">
<Badge slot="eyebrow">Blog</Badge>
{
posts.map((p) => (
<li class="grid min-w-0">
<PostCard href={p.href} title={p.title} date={p.date} excerpt={p.excerpt} image={p.image} topic={p.topic} author={p.author} headingTag={tag} />
</li>
))
}
</Posts>
</div>Minimal · Light