feat: pass source path to markdown parser for icon resolution
Pass the file's base path through the markdown parsing pipeline to allow the icon directive to resolve relative asset paths correctly using an absolute fallback chain.
This commit is contained in:
@@ -6,7 +6,7 @@ import markedTable from "./table";
|
||||
import { gfmHeadingId } from "marked-gfm-heading-id";
|
||||
import markedColumns from "./columns";
|
||||
import markedCodeBlockYamlTag from "./code-block-yaml-tag";
|
||||
import { iconDirective } from "./icon";
|
||||
import { iconDirective, setIconBase } from "./icon";
|
||||
|
||||
// 使用 marked-directive 来支持指令语法
|
||||
const marked = new Marked()
|
||||
@@ -33,7 +33,8 @@ const marked = new Marked()
|
||||
},
|
||||
);
|
||||
|
||||
export function parseMarkdown(content: string): string {
|
||||
export function parseMarkdown(content: string, basePath?: string): string {
|
||||
setIconBase(basePath);
|
||||
return marked.parse(content.trimStart()) as string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user