From 5f06b4d260cf604055a798f405e51d68e20c097b Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Mon, 12 Aug 2019 17:41:48 +0930 Subject: [PATCH] refactor(open_graph): drop cheerio and use regex https://github.com/hexojs/hexo/pull/3680 --- themes/typing/scripts/openGraph.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/themes/typing/scripts/openGraph.js b/themes/typing/scripts/openGraph.js index 8b493e9..804a963 100644 --- a/themes/typing/scripts/openGraph.js +++ b/themes/typing/scripts/openGraph.js @@ -13,7 +13,6 @@ const moment = require('moment') const { escapeHTML, htmlTag, stripHTML } = require('hexo-util') -let cheerio function meta (name, content, escape) { if (escape !== false && typeof content === 'string') { @@ -69,13 +68,12 @@ function openGraphHelper (options = {}) { if (!images.length && content && content.includes(' { - const src = $(element).attr('data-src') - if (src) images.push(src) - }) + // https://github.com/hexojs/hexo/pull/3680 + let img + const imgPattern = /]*src=['"]([^'"]+)([^>]*>)/gi + while ((img = imgPattern.exec(content)) !== null) { + images.push(img[1]) + } } if (description) {