Skip to content

Commit 708eeac

Browse files
author
Luca Forstner
authored
ref: Refactor changelog list page (#11019)
1 parent 450cdfb commit 708eeac

File tree

9 files changed

+318
-190
lines changed

9 files changed

+318
-190
lines changed

apps/changelog/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"next-auth": "^4.24.5",
2828
"next-mdx-remote": "^4.4.1",
2929
"nextjs-toploader": "^1.6.6",
30+
"nuqs": "^1.17.7",
3031
"prism-sentry": "^1.0.2",
3132
"react": "beta",
3233
"react-dom": "beta",

apps/changelog/src/app/changelog/%5Fadmin/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ export default async function ChangelogsListPage() {
103103
<span className="text-gray-500">
104104
<Text size="1">
105105
{' '}
106-
{new Date(changelog.publishedAt || '').toLocaleDateString(
107-
undefined,
108-
{month: 'long', day: 'numeric'}
109-
)}
106+
{new Date(changelog.publishedAt || '').toLocaleDateString('en-EN', {
107+
month: 'long',
108+
day: 'numeric',
109+
timeZone: 'UTC',
110+
})}
110111
</Text>
111112
<br />
112113
</span>

apps/changelog/src/app/changelog/page.tsx

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
1-
import { Fragment } from "react";
2-
import type { Metadata } from "next";
3-
import { serialize } from "next-mdx-remote/serialize";
1+
import {Fragment} from 'react';
2+
import type {Metadata} from 'next';
3+
import {serialize} from 'next-mdx-remote/serialize';
44

5-
import Header from "./header";
6-
import { getChangelogs } from "../../server/utils";
7-
import List from "@/client/components/list";
5+
import Header from './header';
6+
import {getChangelogs} from '../../server/utils';
7+
import {ChangelogEntry, ChangelogList} from '@/client/components/list';
8+
import {startSpan} from '@sentry/nextjs';
89

9-
export const dynamic = "force-dynamic";
10+
export const dynamic = 'force-dynamic';
1011

11-
export default async function ChangelogList() {
12+
export default async function Page() {
1213
const changelogs = await getChangelogs();
1314

14-
const changelogsWithMdxSummaries = await Promise.all(
15-
changelogs.map(async (changelog) => {
16-
const mdxSummary = await serialize(changelog.summary || "");
17-
return {
18-
...changelog,
19-
mdxSummary,
20-
};
21-
})
15+
const changelogsWithPublishedAt = changelogs.filter(changelog => {
16+
return changelog.publishedAt !== null;
17+
});
18+
19+
const changelogsWithMdxSummaries = await startSpan(
20+
{name: 'serialize changelog summaries'},
21+
() =>
22+
Promise.all(
23+
changelogsWithPublishedAt.map(async (changelog): Promise<ChangelogEntry> => {
24+
const mdxSummary = await serialize(changelog.summary || '');
25+
return {
26+
id: changelog.id,
27+
title: changelog.title,
28+
slug: changelog.slug,
29+
// Because `getChangelogs` is cached, it sometimes returns its results serialized and sometimes not. Therefore we have to deserialize the string to be able to call toUTCString().
30+
publishedAt: new Date(changelog.publishedAt!).toUTCString(),
31+
categories: changelog.categories,
32+
mdxSummary,
33+
};
34+
})
35+
)
2236
);
2337

2438
return (
2539
<Fragment>
2640
<Header />
27-
<List changelogs={changelogsWithMdxSummaries} />
41+
<ChangelogList changelogs={changelogsWithMdxSummaries} />
2842
</Fragment>
2943
);
3044
}
3145

3246
export function generateMetadata(): Metadata {
3347
return {
3448
description:
35-
"Stay up to date on everything big and small, from product updates to SDK changes with the Sentry Changelog.",
49+
'Stay up to date on everything big and small, from product updates to SDK changes with the Sentry Changelog.',
3650
alternates: {
3751
canonical: `https://sentry.io/changelog/`,
3852
},

apps/changelog/src/client/components/article.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ReactNode} from 'react';
2-
import Tag from './tag';
3-
import { DateComponent } from './date';
2+
import {DateComponent} from './date';
3+
import {CategoryTag} from './tag';
44

55
type ArticleProps = {
66
children?: ReactNode;
@@ -41,7 +41,7 @@ export default function Article({
4141
<h3 className="text-3xl text-primary font-semibold mb-2">{title}</h3>
4242
<div>
4343
<div className="flex flex-wrap gap-1 py-1">
44-
{Array.isArray(tags) && tags.map(tag => <Tag key={tag} text={tag} />)}
44+
{Array.isArray(tags) && tags.map(tag => <CategoryTag key={tag} text={tag} />)}
4545
</div>
4646

4747
<div className="prose max-w-none text-gray-700 py-2">{children}</div>

apps/changelog/src/client/components/date.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const formatDate = (date: string | Date) => {
2-
const options: Intl.DateTimeFormatOptions = {
2+
const now = new Date(date).toLocaleDateString('en-EN', {
33
year: 'numeric',
44
month: 'long',
55
day: 'numeric',
66
timeZone: 'UTC'
7-
};
8-
const now = new Date(date).toLocaleDateString('en-EN', options);
7+
});
98

109
return now;
1110
};

0 commit comments

Comments
 (0)