fix: md path

This commit is contained in:
2026-02-26 01:15:40 +08:00
parent 3f61e63709
commit 3098328a27
2 changed files with 14 additions and 5 deletions
+3 -3
View File
@@ -17,11 +17,11 @@ customElement('md-table', { roll: false, remix: false }, (props, { element }) =>
// 从 element 的 textContent 获取 CSV 路径
const src = element?.textContent?.trim() || '';
// 从父节点 article 的 data-src 获取当前 markdown 文件路径
// 从父节点 article 的 data-src 获取当前 markdown 文件完整路径
const articleEl = element?.closest('article[data-src]');
const articlePath = articleEl?.getAttribute('data-src') || '';
// 解析相对路径
// 解析相对路径(相对于 markdown 文件所在目录)
const resolvePath = (base: string, relative: string): string => {
if (relative.startsWith('/')) {
return relative;
@@ -30,7 +30,7 @@ customElement('md-table', { roll: false, remix: false }, (props, { element }) =>
return baseDir + relative;
};
const resolvedSrc = resolvePath(`/content/${articlePath}`, src);
const resolvedSrc = resolvePath(articlePath, src);
// 解析 CSV 内容
const parseCSV = (content: string) => {