Feature: 产品列表增加页头 & Markdown渲染器增加图像Url转换功能

This commit is contained in:
2025-08-21 14:26:58 +08:00
parent 0a31a1fa85
commit 2fe8797551
7 changed files with 86 additions and 39 deletions

View File

@ -19,3 +19,16 @@ export function renderMarkdown(content: string): string {
return dirtyHtml
}
export function convertMedia(content: string): string {
// 通过正则表达式替换Markdown中的图片链接
// ![alt text](image-url) -> ![alt text](strapiMedia(image-url))
if(!content) return '';
const contentWithAbsoluteUrls = content.replace(
/!\[([^\]]*)\]\((\/uploads\/[^)]+)\)/g,
(_, alt, url) => `![${alt}](${useStrapiMedia(url)})`
)
return contentWithAbsoluteUrls;
}