Files
jinshen-website/app/utils/markdown.ts
R2m1liA 17d10a7d80
All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m37s
chore: 移除部分无用代码
2025-11-14 11:06:09 +08:00

21 lines
411 B
TypeScript

import MarkdownIt from 'markdown-it';
const md = new MarkdownIt({
html: true,
linkify: true,
typographer: true,
breaks: true,
});
export function renderMarkdown(content: string): string {
const dirtyHtml = md.render(content);
if (typeof window !== 'undefined') {
import('dompurify').then((DOMPurify) => {
return DOMPurify.default.sanitize(dirtyHtml);
});
}
return dirtyHtml;
}