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:
2026-07-08 16:38:19 +08:00
parent 2dba19e1f8
commit 6ab6b76978
5 changed files with 35 additions and 14 deletions
+3 -2
View File
@@ -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;
}