Marketing sectionsPostCompact
Searchastronomic.dev# PostCompact
For a short list of post titles and dates, such as on a home page or beside other content.
Static: no JavaScript.
## Usage
```astro
import PostCompact from "@astronomic/ui-pro/components/PostCompact.astro";
```
## Examples
### In a narrow column
Five post titles with their dates in a 24rem column, such as beside a page's main text or at the foot of a home page, then the link to all posts. Each row is on a hairline, with a tighter padding than PostList: the date first, above the title (from a 42rem posts container it takes its own start column, as PostList). There is no heading of its own here, so the titles are h3 under the page's h2.
```astro
---
import PostCompact from "@astronomic/ui-pro/components/PostCompact.astro";
import { displayType } from "@astronomic-dev/ui/lib/display.ts";
// Titles and dates only: a picture, excerpt, topic or author given here is not shown. Newest first.
const posts = [
{ href: "#launch-checklist", title: "A launch checklist for a small studio site", date: "2026-10-14" },
{ href: "#sketch-first", title: "Sketch the page before the first pixel", date: "2026-10-02" },
{ href: "#content-move", title: "Moving an old site's content without losing a page", date: "2026-09-18" },
{ href: "#editors", title: "Letting editors change pages without breaking them", date: "2026-09-04" },
{ href: "#fonts", title: "Choosing two fonts for a site", date: "2026-08-21" },
];
---
<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}`}>Beside the page</h2>
<PostCompact items={posts} viewAll={{ label: "All posts", href: "#blog" }} />
</div>
</div>
```
## Props
### PostCompact
| 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. Each row shows only the title and the date (or dateLabel). All are shown: pass only as many as you want. |
| `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. |
| 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.
PostCompact
ProFor a short list of post titles and dates, such as on a home page or beside other content.
- File
- PostCompact.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
In a narrow column
Five post titles with their dates in a 24rem column, such as beside a page's main text or at the foot of a home page, then the link to all posts. Each row is on a hairline, with a tighter padding than PostList: the date first, above the title (from a 42rem posts container it takes its own start column, as PostList). There is no heading of its own here, so the titles are h3 under the page's h2.
This preview did not load.
main.astro
examples/postcompact/main.astro
---
import PostCompact from "@astronomic/ui-pro/components/PostCompact.astro";
import { displayType } from "@astronomic-dev/ui/lib/display.ts";
// Titles and dates only: a picture, excerpt, topic or author given here is not shown. Newest first.
const posts = [
{ href: "#launch-checklist", title: "A launch checklist for a small studio site", date: "2026-10-14" },
{ href: "#sketch-first", title: "Sketch the page before the first pixel", date: "2026-10-02" },
{ href: "#content-move", title: "Moving an old site's content without losing a page", date: "2026-09-18" },
{ href: "#editors", title: "Letting editors change pages without breaking them", date: "2026-09-04" },
{ href: "#fonts", title: "Choosing two fonts for a site", date: "2026-08-21" },
];
---
<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}`}>Beside the page</h2>
<PostCompact items={posts} viewAll={{ label: "All posts", href: "#blog" }} />
</div>
</div>Minimal · Light