feat: add tocs feature & fix page element generation issue (#9).

This commit is contained in:
jaywcjlove
2022-10-28 22:07:12 +08:00
parent 6d0801a9da
commit dd8a3cb26d
9 changed files with 197 additions and 29 deletions

View File

@ -1,8 +1,11 @@
import fs from 'fs-extra';
import path from 'path';
import rehypeParse from 'rehype-parse';
import {unified} from 'unified';
import { VFile } from 'vfile';
export const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets')
export function getSVGNode(iconPath, space = 'svg') {
const svgStr = fs.readFileSync(iconPath);
const processor = unified().use(rehypeParse,{ fragment: true, space })