Skip to content

Commit 4fc9a79

Browse files
Render release notes markdown on releases page
Replace the truncated plain-text release body with a dedicated `ReleaseBody` component that renders GitHub-flavored markdown, trims common boilerplate headers, and applies scoped typography styles for release content. Also update the download link to use `findWindowsInstaller` so the releases page points to the intended Windows installer asset instead of the first asset.
1 parent d52a4d1 commit 4fc9a79

3 files changed

Lines changed: 59 additions & 12 deletions

File tree

app/globals.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,26 @@
164164
.doc-content ol {
165165
@apply list-decimal pl-6;
166166
}
167+
168+
.release-body h2,
169+
.release-body h3,
170+
.release-body h4 {
171+
@apply mt-4 mb-2 text-base;
172+
}
173+
174+
.release-body p,
175+
.release-body ul,
176+
.release-body ol {
177+
@apply my-2;
178+
}
179+
180+
.release-body li {
181+
@apply my-0.5;
182+
}
183+
184+
.release-body strong {
185+
@apply font-semibold text-foreground;
186+
}
167187
}
168188

169189
.text-hero {

app/releases/page.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { Metadata } from "next";
22
import Link from "next/link";
3-
import { formatReleaseDate, getReleases } from "@/lib/github";
3+
import { ReleaseBody } from "@/components/release-body";
4+
import {
5+
findWindowsInstaller,
6+
formatReleaseDate,
7+
getReleases,
8+
} from "@/lib/github";
49

510
import { buildPageMetadata } from "@/lib/page-metadata";
611

@@ -23,7 +28,9 @@ export default async function ReleasesPage() {
2328
{releases.length === 0 ? (
2429
<li className="text-muted-foreground">No releases found.</li>
2530
) : (
26-
releases.map((r) => (
31+
releases.map((r) => {
32+
const installer = findWindowsInstaller(r);
33+
return (
2734
<li
2835
key={r.tag_name}
2936
className="rounded-xl border border-border p-6"
@@ -34,12 +41,7 @@ export default async function ReleasesPage() {
3441
{formatReleaseDate(r.published_at)}
3542
</time>
3643
</div>
37-
{r.body ? (
38-
<p className="mt-3 line-clamp-4 text-sm text-muted-foreground whitespace-pre-wrap">
39-
{r.body.slice(0, 400)}
40-
{r.body.length > 400 ? "…" : ""}
41-
</p>
42-
) : null}
44+
{r.body ? <ReleaseBody body={r.body} /> : null}
4345
<div className="mt-4 flex flex-wrap gap-3 text-sm">
4446
<a
4547
href={r.html_url}
@@ -49,17 +51,18 @@ export default async function ReleasesPage() {
4951
>
5052
View on GitHub
5153
</a>
52-
{r.assets[0] ? (
54+
{installer ? (
5355
<a
54-
href={r.assets[0].browser_download_url}
56+
href={installer.browser_download_url}
5557
className="text-primary hover:underline"
5658
>
57-
Download {r.assets[0].name}
59+
Download {installer.name}
5860
</a>
5961
) : null}
6062
</div>
6163
</li>
62-
))
64+
);
65+
})
6366
)}
6467
</ul>
6568
<p className="mt-8">

components/release-body.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import ReactMarkdown from "react-markdown";
2+
import remarkGfm from "remark-gfm";
3+
4+
function prepareReleaseBody(body: string): string {
5+
let text = body.trim();
6+
text = text.replace(/^#\s+.+\n+/, "");
7+
text = text.replace(/^\*\*[^*\n]+\*\*\s*\n+/, "");
8+
return text.trim();
9+
}
10+
11+
type ReleaseBodyProps = {
12+
body: string;
13+
};
14+
15+
export function ReleaseBody({ body }: ReleaseBodyProps) {
16+
const markdown = prepareReleaseBody(body);
17+
if (!markdown) return null;
18+
19+
return (
20+
<div className="release-body doc-content prose-no-margin mt-3 text-sm text-muted-foreground">
21+
<ReactMarkdown remarkPlugins={[remarkGfm]}>{markdown}</ReactMarkdown>
22+
</div>
23+
);
24+
}

0 commit comments

Comments
 (0)