From 2e906df38468faa5a54f203a0f7bb0eff4dbfa42 Mon Sep 17 00:00:00 2001 From: crimx Date: Sat, 3 Oct 2020 11:34:27 +0800 Subject: [PATCH] fix: check options.enable --- README.md | 2 +- index.js | 43 +++++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e12206b..284c9e5 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ githubEmojis: ``` - **inject** `boolean=true` - Inject emoji styles and fallback script. - If `true`, the filter will inject a `` + data.content; - } - } else { - const $content = new JSDOM(data.content); - const $excerpt = new JSDOM(data.excerpt); - - replaceColons($content.window.document.body, emojis); - replaceColons($excerpt.window.document.body, emojis); - - if (options.inject !== false) { - const style = $content.window.document.createElement("style"); - style.innerHTML = getEmojiStyles(); - $content.window.document.body.insertBefore( - style, - $content.window.document.body.firstElementChild - ); - } - - data.content = $content.window.document.body.innerHTML; - data.excerpt = $excerpt.window.document.body.innerHTML; + if (options.inject !== false && (!options.enable || data["no-emoji"])) { + data.content = `` + data.content; + return data } + const $content = new JSDOM(data.content); + const $excerpt = new JSDOM(data.excerpt); + + replaceColons($content.window.document.body, emojis); + replaceColons($excerpt.window.document.body, emojis); + + if (options.inject !== false) { + const style = $content.window.document.createElement("style"); + style.innerHTML = getEmojiStyles(); + $content.window.document.body.insertBefore( + style, + $content.window.document.body.firstElementChild + ); + } + + data.content = $content.window.document.body.innerHTML; + data.excerpt = $excerpt.window.document.body.innerHTML; + return data; });