mirror of https://gitlab.com/curben/blog
fix(open_graph): lazy load cheerio
This commit is contained in:
parent
1f9a2bc56e
commit
9d94a13f94
|
@ -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 () {
|
||||
|
|
Loading…
Reference in New Issue