NavigationSeriesPager
Searchastronomic.dev# SeriesPager
At the end of a post in a series: links to the part before and the part after.
Static: no JavaScript.
## Usage
```astro
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
```
## Examples
### Before and after
The part before and the part after this one, side by side from a 28rem nav and stacked below, then "All parts" to the series page.
```astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
const parts = [
{ title: "Plan the launch", href: "#part-1" },
{ title: "Write the pages", href: "#part-2", current: true },
{ title: "Ship it before the long weekend", href: "#part-3" },
{ title: "Look back" },
];
---
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={parts} />
</div>
```
### The first part
No previous part: the next link keeps its end column.
```astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
const parts = [
{ title: "Plan the launch", href: "#part-1", current: true },
{ title: "Write the pages", href: "#part-2" },
{ title: "Ship it", href: "#part-3" },
];
---
<!-- The first part: no previous part; the next link keeps its end column. -->
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={parts} />
</div>
```
### The last part
No next part: the previous link keeps its start column.
```astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
const parts = [
{ title: "Plan the launch", href: "#part-1" },
{ title: "Write the pages", href: "#part-2" },
{ title: "Ship it", href: "#part-3", current: true },
];
---
<!-- The last part: no next part; the previous link keeps its start column. -->
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={parts} />
</div>
```
### One part so far
No previous or next: the heading, the position and "All parts".
```astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
---
<!-- A series of one so far: the heading, the position and the link to the series page. -->
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={[{ title: "Plan the launch", current: true }]} />
</div>
```
## Props
### SeriesPager
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | None | Required. The series name, such as "The Last Diners": the nav's heading. |
| `href` | `string` | None | The series page. With it, the name in the heading is a link. |
| `label` | `string` | None | Text before the name, such as "Series", muted, with a middle dot. |
| `parts` | `SeriesPart[]` | None | Required, one or more: { title, href?, meta?, current? } (SeriesPart), in order. href is the part's page; without it (not out yet) the title is plain text. meta is your own text, such as "Oct 16 · Members". current marks the part on this page: one at most. The pager needs exactly one current part: none stops the build. |
| `positionText` | `string` | `"Part {part} of {total}"` | Where this part sits; {part} and {total} are filled in. Shown only with a current part. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The heading element. |
| `class` | `string` | None | More classes for the <nav>, merged with cn(). The nav is a named size container (series). |
| `previousLabel` | `string` | `"Previous part"` | The previous link's label. |
| `nextLabel` | `string` | `"Next part"` | The next link's label. |
| `allLabel` | `string` | `"All parts"` | The link to the series page (href). Shown only with href. |
Any other attribute goes on the <nav>.
## Accessibility
- Renders a <nav> named by the series heading, so it is a navigation landmark of its own. Two series navs for the same series on one page (a list at the top, a pager at the end) share that name: give one its own aria-label (or aria-labelledby), which goes on the <nav> through the other attributes.
- The label's middle dot is hidden from screen readers.
- The position line ("Part 2 of 4") comes from the one current part. More than one current part stops the build; no parts stop it too.
- Each side is one link whose text says which way it goes ("Previous part") and to which title. A side that is not out yet is left out.
- Each link is a whole box, far above 44px; "All parts" has a 44px hit area on touch screens.
SeriesPager
FreeAt the end of a post in a series: links to the part before and the part after.
- File
- SeriesPager.astro
- Group
- Navigation
- Kind
- Static: no JavaScript
- Examples
- 4
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Before and after
The part before and the part after this one, side by side from a 28rem nav and stacked below, then "All parts" to the series page.
This preview did not load.
main.astro
examples/seriespager/main.astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
const parts = [
{ title: "Plan the launch", href: "#part-1" },
{ title: "Write the pages", href: "#part-2", current: true },
{ title: "Ship it before the long weekend", href: "#part-3" },
{ title: "Look back" },
];
---
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={parts} />
</div>The first part
No previous part: the next link keeps its end column.
This preview did not load.
first.astro
examples/seriespager/first.astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
const parts = [
{ title: "Plan the launch", href: "#part-1", current: true },
{ title: "Write the pages", href: "#part-2" },
{ title: "Ship it", href: "#part-3" },
];
---
<!-- The first part: no previous part; the next link keeps its end column. -->
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={parts} />
</div>The last part
No next part: the previous link keeps its start column.
This preview did not load.
last.astro
examples/seriespager/last.astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
const parts = [
{ title: "Plan the launch", href: "#part-1" },
{ title: "Write the pages", href: "#part-2" },
{ title: "Ship it", href: "#part-3", current: true },
];
---
<!-- The last part: no next part; the previous link keeps its start column. -->
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={parts} />
</div>One part so far
No previous or next: the heading, the position and "All parts".
This preview did not load.
single.astro
examples/seriespager/single.astro
---
import SeriesPager from "@astronomic-dev/ui/components/SeriesPager.astro";
---
<!-- A series of one so far: the heading, the position and the link to the series page. -->
<div class="mx-auto max-w-2xl">
<SeriesPager title="Launch notes" label="Series" href="#series-launch" parts={[{ title: "Plan the launch", current: true }]} />
</div>Minimal · Light