summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2026-01-30 23:10:01 +0100
committerDawid Rycerz <dawid@rycerz.xyz>2026-01-30 23:11:52 +0100
commit49630682783c74bb74efc13e5261bdb1d22b253a (patch)
tree2c01349817803ba667df07a70202d30ce1158f5b
parent87a71529cf743f1c84da7b39deb09c5e4a99225d (diff)
feat(tags): replace pagination with year-grouped single page
Remove pagination from tag pages and show all posts on one page. Tags with >20 posts group entries by year with headers matching the main posts page style. Tags with <=20 posts keep a flat list. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
-rw-r--r--SPRINT.md6
-rw-r--r--src/pages/tags/[tag]/index.astro (renamed from src/pages/tags/[tag]/[...page].astro)82
2 files changed, 42 insertions, 46 deletions
diff --git a/SPRINT.md b/SPRINT.md
index 05d7ee1..65150e5 100644
--- a/SPRINT.md
+++ b/SPRINT.md
@@ -7,11 +7,11 @@ Goal: Initialize project tooling for Claude Code
## In Progress
## Backlog (Prioritized)
-- [ ] **[FEATURE-004]** Add page number pagination on tag pages
- - Show numbered page links (e.g. "1, 2, 3, ..., 11") on tag listing pages like `/tags/microblog/`
- - Let users see total page count and jump to specific pages
## Completed This Sprint
+- [x] **[FEATURE-004]** Add year grouping to tag pages, remove pagination
+ - Completed: 2026-01-30
+ - Notes: Removed pagination, single page per tag. Tags with >20 posts show year-grouped sections matching main posts page style (commit e000a4d)
- [x] **[FEATURE-003]** Add next/previous post navigation on blog post pages
- Completed: 2026-01-30
- Notes: Category-scoped navigation (regular/microblog/archived) with i18n support (commit 468d7c4)
diff --git a/src/pages/tags/[tag]/[...page].astro b/src/pages/tags/[tag]/index.astro
index 8ae9716..2f7fa47 100644
--- a/src/pages/tags/[tag]/[...page].astro
+++ b/src/pages/tags/[tag]/index.astro
@@ -1,36 +1,26 @@
---
import { render } from "astro:content";
-import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
+import type { GetStaticPaths } from "astro";
import { Icon } from "astro-icon/components";
import PostPreview from "@/components/blog/PostPreview.astro";
-import Pagination from "@/components/Paginator.astro";
-import { getAllPosts, getTagMeta, getUniqueTags } from "@/data/post";
+import { getAllPosts, getTagMeta, getUniqueTags, groupPostsByYear } from "@/data/post";
import PageLayout from "@/layouts/Base.astro";
import { collectionDateSort } from "@/utils/date";
-export const getStaticPaths = (async ({ paginate }) => {
- const allPosts = await getAllPosts(true); // Include archived posts (now includes pleroma too)
-
- // Get unique tags from all posts
+export const getStaticPaths = (async () => {
+ const allPosts = await getAllPosts(true);
const allTags = getUniqueTags(allPosts);
- return allTags.flatMap((tag) => {
- // Filter posts by tag
- const postsWithTag = allPosts.filter((post) => post.data.tags.includes(tag));
-
- // Sort chronologically
- const sortedPosts = postsWithTag.sort(collectionDateSort);
+ return allTags.map((tag) => {
+ const postsWithTag = allPosts
+ .filter((post) => post.data.tags.includes(tag))
+ .sort(collectionDateSort);
- return paginate(sortedPosts, {
- pageSize: 10,
- params: { tag },
- });
+ return { params: { tag }, props: { posts: postsWithTag } };
});
}) satisfies GetStaticPaths;
-type Props = InferGetStaticPropsType<typeof getStaticPaths>;
-
-const { page } = Astro.props as Props;
+const { posts } = Astro.props;
const { tag } = Astro.params;
const tagMeta = await getTagMeta(tag);
@@ -44,20 +34,9 @@ const meta = {
title: tagMeta?.data.title ?? `${tagDisplay} posts`,
};
-const paginationProps = {
- ...(page.url.prev && {
- prevUrl: {
- text: "← Previous posts",
- url: page.url.prev,
- },
- }),
- ...(page.url.next && {
- nextUrl: {
- text: "Next posts →",
- url: page.url.next,
- },
- }),
-};
+const groupedByYear = groupPostsByYear(posts);
+const descYearKeys = Object.keys(groupedByYear).sort((a, b) => +b - +a);
+const useYearGrouping = posts.length > 20;
---
<PageLayout meta={meta}>
@@ -86,14 +65,31 @@ const paginationProps = {
{tagMeta?.data.description && <p>{tagMeta.data.description}</p>}
{TagContent && <TagContent />}
</div>
- <ul class="space-y-6">
- {
- page.data.map((post) => (
- <li class="grid gap-2 sm:grid-cols-[auto_1fr]">
- <PostPreview as="h2" post={post} />
- </li>
+ {
+ useYearGrouping ? (
+ descYearKeys.map((yearKey) => (
+ <section aria-labelledby={`year-${yearKey}`}>
+ <h2 id={`year-${yearKey}`} class="title text-lg">
+ <span class="sr-only">Posts in</span>
+ {yearKey}
+ </h2>
+ <ul class="mt-5 mb-16 space-y-6 text-start">
+ {groupedByYear[yearKey]?.map((post) => (
+ <li class="grid gap-2 sm:grid-cols-[auto_1fr] sm:[&_q]:col-start-2">
+ <PostPreview as="h2" post={post} />
+ </li>
+ ))}
+ </ul>
+ </section>
))
- }
- </ul>
- <Pagination {...paginationProps} />
+ ) : (
+ <ul class="space-y-6">
+ {posts.map((post) => (
+ <li class="grid gap-2 sm:grid-cols-[auto_1fr]">
+ <PostPreview as="h2" post={post} />
+ </li>
+ ))}
+ </ul>
+ )
+ }
</PageLayout>