fix: shorten update notes and contain entry content in cards
This commit is contained in:
@@ -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' : '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user