fix(open_graph): lazy load cheerio

This commit is contained in:
curben 2019-08-11 11:39:48 +09:30
parent 1f9a2bc56e
commit 9d94a13f94
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
1 changed files with 2 additions and 1 deletions

View File

@ -13,7 +13,7 @@
const moment = require('moment')
const { escapeHTML, htmlTag, stripHTML } = require('hexo-util')
const cheerio = require('cheerio')
let cheerio
function meta (name, content, escape) {
if (escape !== false && typeof content === 'string') {
@ -69,6 +69,7 @@ function openGraphHelper (options = {}) {
if (!images.length && content) {
images = images.slice()
if (!cheerio) cheerio = require('cheerio');
const $ = cheerio.load(content)
$('img').each(function () {