From 707a162df891d6c2747e439fe4461ae28d43ba35 Mon Sep 17 00:00:00 2001 From: Kang Miao Date: Sat, 26 Dec 2020 14:13:31 +0800 Subject: [PATCH 1/2] Fixed issue that missing catalog if we just enable multilingual tag but no translation content. --- _includes/footer.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/_includes/footer.html b/_includes/footer.html index 28b6d5796dc..77ba0f15454 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -161,9 +161,13 @@ // interop with multilangual if ('{{ page.multilingual }}' == 'true') { - _containerSelector = 'div.post-container.active' + _containerSelector = 'div.post-container.active'; } else { - _containerSelector = 'div.post-container' + _containerSelector = 'div.post-container'; + } + + if (!$(_containerSelector).length) { + _containerSelector = 'div.post-container'; } // init From b17636c4814ea1bed19c53f3f086a04c534f56a8 Mon Sep 17 00:00:00 2001 From: Kang Miao Date: Sat, 26 Dec 2020 14:42:44 +0800 Subject: [PATCH 2/2] Fixed issue that js broken if we just enable multilingual tag but no translation content. --- _includes/footer.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/_includes/footer.html b/_includes/footer.html index 77ba0f15454..c8d3b0ce124 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -242,19 +242,19 @@ function _render() { var lang = getLang() // en - if (lang == "en") { + if (lang == "en" && $en) { $select.selectedIndex = 1; - $en.style.display = "block"; - $en.classList.add("active"); - $zh.style.display = "none"; - $zh.classList.remove("active"); + $en && ($en.style.display = "block"); + $en && ($en.classList.add("active")); + $zh && ($zh.style.display = "none"); + $zh && ($zh.classList.remove("active")); // default to zh-cn } else { $select.selectedIndex = 0; - $zh.style.display = "block"; - $zh.classList.add("active"); - $en.style.display = "none"; - $en.classList.remove("active"); + $zh && ($zh.style.display = "block"); + $zh && ($zh.classList.add("active")); + $en && ($en.style.display = "none"); + $en && ($en.classList.remove("active")); } // interop with catalog generateCatalog(".catalog-body");