Skip to content

Commit 9b3d756

Browse files
committed
feat: support markdown in notifications
1 parent 5b3eda6 commit 9b3d756

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

site/src/modules/notifications/NotificationsInbox/InboxItem.stories.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ export const LongText: Story = {
4848
},
4949
};
5050

51+
export const Markdown: Story = {
52+
args: {
53+
notification: {
54+
...MockNotification,
55+
read_at: null,
56+
content: "Hello **world**!",
57+
},
58+
},
59+
};
60+
5161
export const UnreadFocus: Story = {
5262
args: {
5363
notification: {

site/src/modules/notifications/NotificationsInbox/InboxItem.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { SquareCheckBig } from "lucide-react";
55
import type { FC } from "react";
66
import { Link as RouterLink } from "react-router-dom";
77
import { relativeTime } from "utils/time";
8+
import Markdown from "react-markdown";
9+
import { cn } from "utils/cn";
810

911
type InboxItemProps = {
1012
notification: InboxNotification;
@@ -26,8 +28,13 @@ export const InboxItem: FC<InboxItemProps> = ({
2628
</div>
2729

2830
<div className="flex flex-col gap-3 flex-1">
29-
<span className="text-content-secondary text-sm font-medium whitespace-break-spaces [overflow-wrap:anywhere]">
30-
{notification.content}
31+
<span
32+
className={cn([
33+
"text-content-secondary text-sm font-medium whitespace-break-spaces [overflow-wrap:anywhere]",
34+
"[&_p]:m-0",
35+
])}
36+
>
37+
<Markdown>{notification.content}</Markdown>
3138
</span>
3239
<div className="flex items-center gap-1">
3340
{notification.actions.map((action) => {

0 commit comments

Comments
 (0)