Feature: 产品列表增加页头 & Markdown渲染器增加图像Url转换功能
This commit is contained in:
@ -19,3 +19,16 @@ export function renderMarkdown(content: string): string {
|
||||
return dirtyHtml
|
||||
}
|
||||
|
||||
export function convertMedia(content: string): string {
|
||||
// 通过正则表达式替换Markdown中的图片链接
|
||||
//  -> )
|
||||
|
||||
if(!content) return '';
|
||||
|
||||
const contentWithAbsoluteUrls = content.replace(
|
||||
/!\[([^\]]*)\]\((\/uploads\/[^)]+)\)/g,
|
||||
(_, alt, url) => `})`
|
||||
)
|
||||
|
||||
return contentWithAbsoluteUrls;
|
||||
}
|
||||
Reference in New Issue
Block a user