From 6ed47d1de76cf4d9edfa85cd6f9e260a3811c9f7 Mon Sep 17 00:00:00 2001 From: Doc Date: Tue, 7 Apr 2026 10:55:08 -0400 Subject: [PATCH 1/8] feat: add support for tags --- src/content.config.ts | 1 + src/pages/news/tags/[tag].astro | 80 +++++++++++++++++++++++++++++++++ src/pages/news/tags/index.astro | 38 ++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 src/pages/news/tags/[tag].astro create mode 100644 src/pages/news/tags/index.astro diff --git a/src/content.config.ts b/src/content.config.ts index bd52c3b3..2a7cb291 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -12,6 +12,7 @@ const posts = defineCollection({ date: z.coerce.date(), author: z.string().default(DEFAULT_AUTHOR), authorAvatar: z.url().default(DEFAULT_AVATAR), + tags: z.array(z.string()).default([]), cover: z .object({ src: z.url(), diff --git a/src/pages/news/tags/[tag].astro b/src/pages/news/tags/[tag].astro new file mode 100644 index 00000000..5cc03ce7 --- /dev/null +++ b/src/pages/news/tags/[tag].astro @@ -0,0 +1,80 @@ +--- +import Layout from "@/layouts/Layout.astro"; +import { getCollection } from "astro:content"; +import { countWords, minutesToRead, truncateForPreview } from "@/utils/content"; +import { formatDateLong } from "@/utils/time.ts"; +import { Icon } from "astro-icon/components"; + +export async function getStaticPaths() { + const allPosts = await getCollection("posts"); + + const uniqueTags = [...new Set(allPosts.map((post: any) => post.data.tags).flat())]; + return uniqueTags.map((tag) => { + const filteredPosts = allPosts.filter((post: any) => post.data.tags.includes(tag)); + const postsWithMeta = filteredPosts.map((p) => { + const words = countWords(p.body ?? ""); + const excerpt = truncateForPreview(p.body ?? "", 512); + return { + ...p, + words, + mins: minutesToRead(words), + excerpt, + }; + }); + return { + params: { tag }, + props: { posts: postsWithMeta }, + }; + }); +} +const { tag } = Astro.params; +const { posts } = Astro.props; +--- + + + + diff --git a/src/pages/news/tags/index.astro b/src/pages/news/tags/index.astro new file mode 100644 index 00000000..09e79b5d --- /dev/null +++ b/src/pages/news/tags/index.astro @@ -0,0 +1,38 @@ +--- +import Layout from "@/layouts/Layout.astro"; +import { getCollection } from "astro:content"; +const allPosts = await getCollection("posts"); +const tags = [...new Set(allPosts.map((post: any) => post.data.tags).flat())]; +--- + + +
+
+

News Tags

+
+
+ { + tags.map((tag) => ( + +
+
+
+

{tag}

+ + Latest + +
+
+
+
+ )) + } +
+
+
+ + From 4fd5f3cf6f2c3da3ddbdfc3c689d13e7a68bf44c Mon Sep 17 00:00:00 2001 From: Doc Date: Tue, 7 Apr 2026 10:57:02 -0400 Subject: [PATCH 2/8] feat: include tags in news index --- src/pages/news/index.astro | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/pages/news/index.astro b/src/pages/news/index.astro index 3e2b85fa..c9138c1c 100644 --- a/src/pages/news/index.astro +++ b/src/pages/news/index.astro @@ -34,11 +34,21 @@ const postsWithMeta = posts.map((p) => {

{entry.data.title}

- {idx === 0 ? ( - - Latest - - ) : null} +
+ {entry.data.tags?.map((tag: string) => ( + + + {tag} + + + + ))} + {idx === 0 ? ( + + Latest + + ) : null} +
From efd5489333958e03b7f2c9ccccbe27455be6b2dd Mon Sep 17 00:00:00 2001 From: Doc Date: Tue, 7 Apr 2026 10:57:17 -0400 Subject: [PATCH 3/8] feat: test a few tags in news --- src/content/posts/1-21-11.mdx | 3 +++ src/content/posts/1-21.mdx | 3 +++ src/content/posts/welcome-to-papermc.mdx | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/content/posts/1-21-11.mdx b/src/content/posts/1-21-11.mdx index e92ef7a7..5e330fdf 100644 --- a/src/content/posts/1-21-11.mdx +++ b/src/content/posts/1-21-11.mdx @@ -2,6 +2,9 @@ title: "1.21.11" date: "2025-12-21T20:00:00Z" author: "Paper Team" +tags: + - "updates" + - "paper" --- ## The 1.21.11 Update diff --git a/src/content/posts/1-21.mdx b/src/content/posts/1-21.mdx index 78bd4a8c..da989a67 100644 --- a/src/content/posts/1-21.mdx +++ b/src/content/posts/1-21.mdx @@ -2,6 +2,9 @@ title: "1.21" date: "2024-07-20T18:00:16.000Z" author: "Paper Team" +tags: + - "updates" + - "paper" --- ## The 1.21 Update diff --git a/src/content/posts/welcome-to-papermc.mdx b/src/content/posts/welcome-to-papermc.mdx index 1e162bd0..9d001f41 100644 --- a/src/content/posts/welcome-to-papermc.mdx +++ b/src/content/posts/welcome-to-papermc.mdx @@ -2,6 +2,8 @@ title: "Welcome to PaperMC" date: "2021-12-14T03:36:05.000Z" author: "Paper Team" +tags: + - "paperchan" --- Welcome to PaperMC! From 3020caa4d5e9f766db92ae58f0b9de8b00466364 Mon Sep 17 00:00:00 2001 From: Doc Date: Tue, 7 Apr 2026 15:24:39 -0400 Subject: [PATCH 4/8] style: format for news index.astro --- src/pages/news/index.astro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/news/index.astro b/src/pages/news/index.astro index c9138c1c..2f21c748 100644 --- a/src/pages/news/index.astro +++ b/src/pages/news/index.astro @@ -41,7 +41,6 @@ const postsWithMeta = posts.map((p) => { {tag} - ))} {idx === 0 ? ( From 4e77a6aca46a0560b48bba6d6553c67ff4c9499f Mon Sep 17 00:00:00 2001 From: Doc Date: Tue, 7 Apr 2026 15:31:06 -0400 Subject: [PATCH 5/8] feat: include tags in footer of the new/post --- src/pages/news/[id].astro | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pages/news/[id].astro b/src/pages/news/[id].astro index 63cd0b29..37f9ddc4 100644 --- a/src/pages/news/[id].astro +++ b/src/pages/news/[id].astro @@ -21,7 +21,7 @@ const mins = minutesToRead(words); const excerpt = truncateForPreview(post.body ?? "", 120); --- - +
@@ -85,6 +85,21 @@ const excerpt = truncateForPreview(post.body ?? "", 120);
{post.data.cover.credit}
) } + + { + post.data.tags && post.data.tags.length > 0 && ( +
+ {post.data.tags.map((tag: string) => ( + + #{tag} + + ))} +
+ ) + }
From 21d456a08cfaca483a1154766902fd6c1716ee97 Mon Sep 17 00:00:00 2001 From: Doc Date: Tue, 7 Apr 2026 15:39:22 -0400 Subject: [PATCH 6/8] feat: change position of tags --- src/pages/news/index.astro | 42 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/pages/news/index.astro b/src/pages/news/index.astro index 2f21c748..563675bf 100644 --- a/src/pages/news/index.astro +++ b/src/pages/news/index.astro @@ -35,13 +35,6 @@ const postsWithMeta = posts.map((p) => {

{entry.data.title}

- {entry.data.tags?.map((tag: string) => ( - - - {tag} - - - ))} {idx === 0 ? ( Latest @@ -51,18 +44,33 @@ const postsWithMeta = posts.map((p) => {
-
- - - {formatDateLong(new Date(entry.data.date))} - +
+
+ + + {formatDateLong(new Date(entry.data.date))} + + + - + + + {entry.mins} min read + +
- - - {entry.mins} min read - + {entry.data.tags && entry.data.tags.length > 0 && ( +
+ {entry.data.tags.map((tag: string) => ( + + {tag} + + ))} +
+ )}
From 7d0fc0ea149abd389ac8c762a50be2fc7888f37e Mon Sep 17 00:00:00 2001 From: Doc Date: Tue, 7 Apr 2026 15:40:43 -0400 Subject: [PATCH 7/8] style: avoid big space for news in container --- src/pages/news/index.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/news/index.astro b/src/pages/news/index.astro index 563675bf..254edeb7 100644 --- a/src/pages/news/index.astro +++ b/src/pages/news/index.astro @@ -30,7 +30,7 @@ const postsWithMeta = posts.map((p) => { { postsWithMeta.map((entry, idx) => ( -