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:
authorChip Zoller <chipzoller@gmail.com>2022-07-24 21:30:39 +0300
committerGitHub <noreply@github.com>2022-07-24 21:30:39 +0300
commit6d90564fef2c4d6783b1e7bfbf2105f81301760e (patch)
tree7caefbd853dc6d4cc2bc369679912018612bdba5
parent26d1949f05a37739e74154ed28a161f6f96401ab (diff)
parent6b41cf77739d06aeb4f4b54757f881c792b6b8e8 (diff)
Merge pull request #348 from chipzoller/fix-search-url
Fix search index url
-rw-r--r--assets/js/functions.js2
-rw-r--r--assets/js/search.js6
-rw-r--r--layouts/_default/baseof.html1
3 files changed, 5 insertions, 4 deletions
diff --git a/assets/js/functions.js b/assets/js/functions.js
index 44908d4..5c7d915 100644
--- a/assets/js/functions.js
+++ b/assets/js/functions.js
@@ -183,7 +183,7 @@ function parseBoolean(string) {
};
function forEach(node, callback) {
- Array.prototype.forEach.call(node.childNodes, callback);
+ node ? Array.prototype.forEach.call(node.childNodes, callback) : false;
}
function wrapText(text, context, wrapper = 'mark') {
diff --git a/assets/js/search.js b/assets/js/search.js
index 7f0b186..13727a3 100644
--- a/assets/js/search.js
+++ b/assets/js/search.js
@@ -116,7 +116,6 @@ function initializeSearch(index) {
searchField.addEventListener('input', function() {
const searchTerm = searchField.value.trim().toLowerCase();
search(searchTerm, searchScope);
- // console.log(searchTerm);
});
if(!searchPageElement) {
@@ -233,8 +232,9 @@ function highlightSearchTerms(search, context, wrapper = 'mark', cssClass = '')
}
window.addEventListener('load', function() {
- const pageLanguage = document.documentElement.lang;
- const searchIndex = `${ pageLanguage === 'en' ? '': pageLanguage}/index.json`;
+ const pageLanguage = elem('body').dataset.lang;
+ const searchIndexLangSlug = pageLanguage === 'en' ? '': `${pageLanguage}/`;
+ const searchIndex = `${searchIndexLangSlug}index.json`;
fetch(new URL(baseURL + searchIndex).href)
.then(response => response.json())
.then(function(data) {
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 7f1da9b..eed5a5e 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -25,6 +25,7 @@
data-code="{{ $codeBlockConfig.max }}"
data-lines="{{ $codeBlockConfig.lines }}"
id="documentTop"
+ data-lang="{{ .Lang }}"
>
{{- partial "header" . }}
<main>