Skip to content

Commit 22ba2f3

Browse files
committed
feat(blog): Implement tag support
1 parent c9f1963 commit 22ba2f3

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

app/lib/mdx-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const frontMatterSchema = z.object({
1313
author: z.string(),
1414
heroImage: z.string().optional(),
1515
heroImageAlt: z.string().optional(),
16+
tags: z.array(z.string()).default([]),
1617
});
1718

1819
export type FrontMatter = z.infer<typeof frontMatterSchema>;

app/routes/blog/$slug.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Calendar, UserPen } from "lucide-react";
33
import { getMDXComponent } from "mdx-bundler/client";
44
import { useMemo } from "react";
55
import { useLoaderData } from "react-router";
6+
import { Badge } from "~/components/ui/badge";
67
import { Separator } from "~/components/ui/separator";
78
import formatDate from "~/lib/format-date";
89
import { getPostBySlug } from "~/lib/mdx-server";
@@ -57,6 +58,15 @@ export default function Post() {
5758
<span>{frontmatter.author}</span>
5859
</div>
5960
</div>
61+
{frontmatter.tags.length > 0 && (
62+
<div className="mb-2 flex flex-wrap gap-1">
63+
{frontmatter.tags.map((tag) => (
64+
<Badge key={tag} variant="outline">
65+
{tag}
66+
</Badge>
67+
))}
68+
</div>
69+
)}
6070
<Separator />
6171
{frontmatter.heroImage && (
6272
<figure>

app/routes/blog/home.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Calendar, UserPen } from "lucide-react";
22
import { useLoaderData } from "react-router";
33
import { Link } from "react-router";
4+
import { Badge } from "~/components/ui/badge";
45
import formatDate from "~/lib/format-date";
56
import { getPosts } from "~/lib/mdx-server";
67

@@ -68,6 +69,15 @@ export default function Home() {
6869
<span>{frontmatter.author}</span>
6970
</div>
7071
</div>
72+
{frontmatter.tags.length > 0 && (
73+
<div className="mt-2 flex flex-wrap gap-1">
74+
{frontmatter.tags.map((tag) => (
75+
<Badge key={tag} variant="outline">
76+
{tag}
77+
</Badge>
78+
))}
79+
</div>
80+
)}
7181
</div>
7282
</Link>
7383
))}

posts/hello.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ published: 2026-04-09
55
author: (niclimcy) Nicholas Lim
66
heroImage: /posts/hello-hero.webp
77
heroImageAlt: "Artemis II Launch, Image Credit: NASA/Bill Ingalls"
8+
tags: ["feature", "breaking-change", "api", "wasmtime"]
89
---
910

1011
```ts

0 commit comments

Comments
 (0)