fix: shorten update notes and contain entry content in cards

This commit is contained in:
2026-09-07 14:15:39 +09:00
parent 98ef813cb5
commit 8f97683271
4 changed files with 48 additions and 13 deletions
+18 -2
View File
@@ -39,10 +39,26 @@ renderer.image = ({ href, title, text }) => {
};
export function renderReleaseMarkdown(markdown: string): string {
return marked.parse(markdown, {
const options = {
async: false,
breaks: true,
gfm: true,
renderer
}) as string;
} as const;
const tokens = marked.lexer(markdown, options);
let html = '';
let entryOpen = false;
for (const token of tokens) {
const boundary = token.type === 'hr' || (token.type === 'heading' && token.depth <= 3);
if (boundary && entryOpen) {
html += '</section>\n';
entryOpen = false;
}
if (token.type === 'heading' && token.depth === 3) {
html += '<section class="update-entry">\n';
entryOpen = true;
}
html += marked.parser([token], options);
}
return html + (entryOpen ? '</section>\n' : '');
}