From e62e3f1760328d9e7234313250b6975da79d6d27 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Sat, 16 Jul 2022 15:35:23 +0800 Subject: [PATCH] :sparkles: Feat: hide content of fixit-encryptor shortcodes from markdown source (#123) --- assets/js/fixit-decryptor.js | 6 +++--- layouts/_default/single.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/js/fixit-decryptor.js b/assets/js/fixit-decryptor.js index 56bbacb5..0e1b8f26 100644 --- a/assets/js/fixit-decryptor.js +++ b/assets/js/fixit-decryptor.js @@ -1,5 +1,5 @@ /** - * FixIt decryptor for encrypted pages + * FixIt decryptor for encrypted pages and fixit-encryptor shortcode * @param {Object} options * @param {Function} [options.decrypted] [Lifecycle Hooks] handler after decrypting * @param {Function} [options.reset] [Lifecycle Hooks] handler after encrypting again @@ -45,7 +45,7 @@ FixItDecryptor = function (options = {}) { this.addEventListener('decrypted', this.options?.decrypted); this.addEventListener('reset', this.options?.reset); this.validateCache(); - + const _decryptor = this; this.$el.querySelector('#fixit-decryptor-input')?.addEventListener('keydown', function (e) { if (e.key === 'Enter') { @@ -135,7 +135,7 @@ FixItDecryptor = function (options = {}) { 'afterbegin', CryptoJS.enc.Base64.parse(base64EncodeContent).toString(CryptoJS.enc.Utf8) ); - $decryptor.parentElement.classList.add('decrypted') + $decryptor.parentElement.classList.add('decrypted'); } catch (err) { return console.error(err); } diff --git a/layouts/_default/single.md b/layouts/_default/single.md index cfd1a13a..f310a21b 100644 --- a/layouts/_default/single.md +++ b/layouts/_default/single.md @@ -4,7 +4,7 @@ {{ if $params.password -}} ***{{ T "encryptedAbstract" }}*** {{- else -}} - {{ .RawContent }} + {{ .RawContent | replaceRE "\n?{{% fixit-encryptor .+ %}}((\n|.)*){{% /fixit-encryptor %}}\n?" "" }} {{- end }} ---