From 0c87728979597eaa0427559ca81eb132675bf7db Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Sat, 30 Dec 2023 01:03:00 +0800 Subject: [PATCH] :bug: Fix: hidden collection navigation, list and related content from encrypted content --- .../_partials/_single/_fixit-decryptor.scss | 4 + assets/js/theme.js | 9 +-- layouts/partials/single/collection-list.html | 2 +- layouts/partials/single/collection-nav.html | 2 +- layouts/partials/single/fixit-decryptor.html | 25 +++--- layouts/partials/single/footer.html | 80 ++++++++++--------- layouts/partials/single/related.html | 2 +- layouts/posts/single.html | 11 +-- 8 files changed, 73 insertions(+), 62 deletions(-) diff --git a/assets/css/_partials/_single/_fixit-decryptor.scss b/assets/css/_partials/_single/_fixit-decryptor.scss index aa2a46d9..06e7261a 100644 --- a/assets/css/_partials/_single/_fixit-decryptor.scss +++ b/assets/css/_partials/_single/_fixit-decryptor.scss @@ -65,3 +65,7 @@ } } } + +.encrypted-hidden { + display: none; +} diff --git a/assets/js/theme.js b/assets/js/theme.js index 51d02c0f..0c2b845c 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -914,7 +914,6 @@ class FixIt { } initFixItDecryptor() { - const $tocNodes = document.querySelectorAll('#toc-auto>.d-none, #toc-static.d-none'); this.decryptor = new FixItDecryptor({ decrypted: () => { this.initTwemoji(); @@ -927,16 +926,16 @@ class FixIt { this.initEcharts(); this.initTypeit(); this.initMapbox(); - this.util.forEach($tocNodes, ($element) => { - $element.classList.remove('d-none'); + this.util.forEach(document.querySelectorAll('.encrypted-hidden'), ($element) => { + $element.classList.replace('encrypted-hidden', 'decrypted-shown'); }); this.initToc(); this.initTocListener(); this.initPangu(); }, reset: () => { - this.util.forEach($tocNodes, ($element) => { - $element.classList.add('d-none'); + this.util.forEach(document.querySelectorAll('.decrypted-shown'), ($element) => { + $element.classList.replace('decrypted-shown', 'encrypted-hidden'); }); } }); diff --git a/layouts/partials/single/collection-list.html b/layouts/partials/single/collection-list.html index c2627591..03efe303 100644 --- a/layouts/partials/single/collection-list.html +++ b/layouts/partials/single/collection-list.html @@ -1,7 +1,7 @@ {{- /* Collection List */ -}} {{- $params := .Scratch.Get "params" -}} -{{- if .Params.collections | and $params.collectionList -}} +{{- if .Params.collections | and $params.collectionList | and (not $params.password) -}} {{- $collectionTerms := .GetTerms "collections" -}} {{- range $collectionTerms -}} {{- $pages := (where .Pages "Params.Weight" "!=" nil) | append (where .Pages "Params.Weight" "eq" nil).ByDate -}} diff --git a/layouts/partials/single/collection-nav.html b/layouts/partials/single/collection-nav.html index fc30897c..94c0c34a 100644 --- a/layouts/partials/single/collection-nav.html +++ b/layouts/partials/single/collection-nav.html @@ -1,7 +1,7 @@ {{- /* Collection Navigation */ -}} {{- $params := .Scratch.Get "params" -}} -{{- if .Params.collections | and $params.collectionNavigation -}} +{{- if .Params.collections | and $params.collectionNavigation | and (not $params.password) -}} {{- $collectionTerms := .GetTerms "collections" -}} {{- range $collectionTerms -}} {{- $termLink := printf `%v %văť%v` diff --git a/layouts/partials/single/fixit-decryptor.html b/layouts/partials/single/fixit-decryptor.html index 422288ab..1aa3a511 100644 --- a/layouts/partials/single/fixit-decryptor.html +++ b/layouts/partials/single/fixit-decryptor.html @@ -1,12 +1,15 @@ -{{- $msg := (.Scratch.Get "params").message | default (T "single.encryptedMessage") -}} -{{- $loading := resources.Get "images/loading.svg" | minify -}} +{{- $params := .Scratch.Get "params" -}} -