refactor: add pull-2, icon label, icon repeat

This commit is contained in:
2026-04-09 12:31:07 +08:00
parent 2aaca2c56f
commit 348dff82f4
2 changed files with 33 additions and 2 deletions
+10 -1
View File
@@ -59,8 +59,17 @@ const marked = new Marked()
}
}
const label = token.attrs?.label as string | undefined;
const inner = label ? `<span class="icon-label-stroke">${label}</span><span class="icon-label">${label}</span>` : "";
const style = globalIconPrefix ? `style="--icon-src: url('${globalIconPrefix}/${iconName}.${extension}')"` : '';
return `<icon ${style} class="icon-${iconName} ${token.attrs?.class || ""}"></icon>`;
const iconHtml = `<icon ${style} class="icon-${iconName} ${token.attrs?.class || ""}">${inner}</icon>`;
const repeat = parseInt(`${token.attrs?.repeat || ''}`);
const join = token.attrs?.join || '';
const separator = join ? `<${join}></${join}>` : '';
if(isNaN(repeat) || repeat < 1) return iconHtml;
return Array(repeat).fill(iconHtml).join(separator);
}
return false;
}