Skip to content

Commit 1943a4d

Browse files
committed
feat: changelog now supports markdown within entries
1 parent 3eccc2f commit 1943a4d

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

apps/web/src/app/changelog/components/release.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ReactNode } from "react";
22
import Link from "next/link";
33
import { cn } from "@/utils/ui";
4+
import { ReactMarkdownWrapper } from "@/components/ui/react-markdown-wrapper";
45
import {
56
getSectionTitle,
67
groupAndOrderChanges,
@@ -144,7 +145,7 @@ function ReleaseChangeList({
144145
key={change.text}
145146
className="text-base leading-relaxed text-foreground"
146147
>
147-
{change.text}
148+
<ReactMarkdownWrapper inline>{change.text}</ReactMarkdownWrapper>
148149
</li>
149150
))}
150151
</ul>

apps/web/src/components/ui/react-markdown-wrapper.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import ReactMarkdown from "react-markdown";
22
import { cn } from "@/utils/ui";
33

4-
export function ReactMarkdownWrapper({ children }: { children: string }) {
4+
export function ReactMarkdownWrapper({
5+
children,
6+
inline = false,
7+
}: {
8+
children: string;
9+
inline?: boolean;
10+
}) {
511
return (
612
<ReactMarkdown
713
components={{
@@ -18,6 +24,27 @@ export function ReactMarkdownWrapper({ children }: { children: string }) {
1824
strong: ({ children }) => (
1925
<strong className="text-foreground font-semibold">{children}</strong>
2026
),
27+
code: ({ className: codeClassName, children, ...props }) => (
28+
<code
29+
className={cn(
30+
"rounded border border-destructive/20 bg-destructive/5 px-1.5 py-0.5 font-mono text-[0.85em] text-red-700 dark:text-red-300",
31+
codeClassName,
32+
)}
33+
{...props}
34+
>
35+
{children}
36+
</code>
37+
),
38+
p: ({ className: paragraphClassName, children, ...props }) =>
39+
inline ? (
40+
<span className={cn("m-0", paragraphClassName)} {...props}>
41+
{children}
42+
</span>
43+
) : (
44+
<p className={cn("m-0", paragraphClassName)} {...props}>
45+
{children}
46+
</p>
47+
),
2148
}}
2249
>
2350
{children}

0 commit comments

Comments
 (0)