mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 04:31:22 +08:00
chore: format script code.
This commit is contained in:
@ -1,24 +1,24 @@
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import rehypeParse from 'rehype-parse';
|
||||
import {unified} from 'unified';
|
||||
import { unified } from 'unified';
|
||||
import { VFile } from 'vfile';
|
||||
|
||||
export const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets')
|
||||
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 })
|
||||
const processor = unified().use(rehypeParse, { fragment: true, space });
|
||||
const file = new VFile();
|
||||
file.value = svgStr.toString();
|
||||
const hastNode = processor.runSync(processor.parse(file), file);
|
||||
return hastNode.children || []
|
||||
return hastNode.children || [];
|
||||
}
|
||||
|
||||
export function getVNode(str = '', space = 'html') {
|
||||
const processor = unified().use(rehypeParse,{ fragment: true, space })
|
||||
const processor = unified().use(rehypeParse, { fragment: true, space });
|
||||
const file = new VFile();
|
||||
file.value = str.toString();
|
||||
const hastNode = processor.runSync(processor.parse(file), file);
|
||||
return hastNode.children || []
|
||||
}
|
||||
return hastNode.children || [];
|
||||
}
|
||||
|
Reference in New Issue
Block a user