Skip to content

Commit e8d5f98

Browse files
feat: support markdown in notifications (#17075)
To make the notification content more appealing, we are sending the notification content as markdown from the server, so we need to adjust the FE to display it properly.
1 parent 5b3eda6 commit e8d5f98

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { Avatar } from "components/Avatar/Avatar";
33
import { Button } from "components/Button/Button";
44
import { SquareCheckBig } from "lucide-react";
55
import type { FC } from "react";
6+
import Markdown from "react-markdown";
67
import { Link as RouterLink } from "react-router-dom";
8+
import { cn } from "utils/cn";
79
import { relativeTime } from "utils/time";
810

911
type InboxItemProps = {
@@ -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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy