Skip to content

Commit 3eccc2f

Browse files
committed
fix: copy to markdown formatting
1 parent 368a20d commit 3eccc2f

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

apps/web/src/app/changelog/components/copy-markdown-button.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ function buildMarkdown({
2929
for (const type of orderedTypes) {
3030
if (isSectionCollapsible({ type })) {
3131
lines.push(
32-
"<details>",
33-
`<summary>${getSectionTitle({ type })}</summary>`,
32+
buildCollapsibleMarkdownSection({
33+
title: getSectionTitle({ type }),
34+
changes: grouped[type],
35+
}),
3436
"",
3537
);
36-
for (const change of grouped[type]) {
37-
lines.push(`- ${change.text}`);
38-
}
39-
lines.push("", "</details>", "");
4038
continue;
4139
}
4240

@@ -50,6 +48,18 @@ function buildMarkdown({
5048
return lines.join("\n").trimEnd();
5149
}
5250

51+
function buildCollapsibleMarkdownSection({
52+
title,
53+
changes,
54+
}: {
55+
title: string;
56+
changes: Change[];
57+
}): string {
58+
const bulletLines = changes.map((change) => `- ${change.text}`).join("\n");
59+
60+
return `<details>\n<summary>${title}</summary>\n\n${bulletLines}\n\n</details>`;
61+
}
62+
5363
export function CopyMarkdownButton({
5464
description,
5565
changes,

0 commit comments

Comments
 (0)