UNPKG

hexo-blogger-xml

Version:

Import xml blogger to hexo

20 lines (16 loc) 457 B
import { existsSync, PathLike, readFileSync } from 'fs'; import { JSDOM } from 'jsdom'; export function fromFile(path: string | PathLike) { if (existsSync(path)) { const dom = new JSDOM(readFileSync(path)); return dom; } return false; } export function fromString(str: string) { return new JSDOM(str); } export function title(str: string) { const dom = new JSDOM(str); return dom.window.document.querySelector('title').textContent; }