Skip to content

Commit 7168b6d

Browse files
committed
optimize exported Markdown style, treat user input as H2
1 parent 1e6359b commit 7168b6d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/app/components/Share/MarkdownView.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ const MarkdownView: FC<Props> = ({ messages }) => {
1313
const content = useMemo(() => {
1414
return messages
1515
.filter((m) => !!m.text)
16-
.map((m) => `**${m.author}**: ` + m.text)
17-
.join('\n\n')
18-
}, [messages])
19-
16+
.map((m) => {
17+
// Check if author is "user"
18+
if (m.author === "user") {
19+
// Format as an h2 markdown element
20+
return `## ${m.author}: ${m.text}`;
21+
} else {
22+
return `**${m.author}**: ${m.text}`;
23+
}
24+
})
25+
.join('\n\n');
26+
}, [messages]);
27+
2028
const copy = useCallback(() => {
2129
navigator.clipboard.writeText(content)
2230
setCopied(true)

0 commit comments

Comments
 (0)