Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/chipzoller/hugo-clarity.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Boothe <git@rootwork.org>2022-06-16 03:33:53 +0300
committerIvan Boothe <git@rootwork.org>2022-06-16 03:33:53 +0300
commitee188c3417982c04e1f75a8e4919f0192a0f020a (patch)
treee0ac0f65f3167aeba89415d0f3d0767369362437
parentada00f3a5f861dd09449d014f0b0d24a814c1c28 (diff)
Restrict search-term highlighting to post_body element
Signed-off-by: Ivan Boothe <git@rootwork.org>
-rw-r--r--assets/js/search.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/assets/js/search.js b/assets/js/search.js
index d3f7e2f..deeaedb 100644
--- a/assets/js/search.js
+++ b/assets/js/search.js
@@ -195,7 +195,7 @@ function initializeSearch(index) {
searchPageElement ? false : liveSearch();
passiveSearch();
- highlightSearch(findQuery(), main, 'mark', 'search-term');
+ highlightSearch(findQuery(), '.post_body', 'mark', 'search-term');
onEscape(clearSearchResults);
@@ -208,7 +208,8 @@ function initializeSearch(index) {
});
}
-function highlightSearch(search, container, wrapper = 'mark', cssClass = '') {
+function highlightSearch(search, context, wrapper = 'mark', cssClass = '') {
+ let container = document.querySelector(context);
let reg = new RegExp("(" + search + ")", "gi");
function highlightSearchInNode(parentNode, search) {