Skip to content

Commit e832126

Browse files
committed
refactor: Update language toggle logic in header.html
1 parent eb8c3f9 commit e832126

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed
File renamed without changes.

layouts/partials/header.html

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<header class="nav flex flex-row row py-2 mb-6 w-full border-b border-gray-300 dark:border-gray-700 justify-between">
22
<div>
3-
<a class="no-underline p-2 rounded hover:bg-gray-200 dark:hover:bg-gray-800" href="{{ .Site.BaseURL }}">Home</a>
4-
<a class="no-underline p-2 rounded hover:bg-gray-200 dark:hover:bg-gray-800"
5-
href="{{ `publication-list` | relURL }}">Publications</a>
6-
{{/* <a class="no-underline p-2 rounded hover:bg-gray-200 dark:hover:bg-gray-800"
7-
href="{{ `blog` | relURL }}">Blog</a> */}}
3+
<a class='no-underline p-2 rounded hover:bg-gray-200 dark:hover:bg-gray-800' href='{{ "/" | relLangURL }}'>Home</a>
4+
<a class="no-underline p-2 rounded hover:bg-gray-200 dark:hover:bg-gray-800" href='{{ "publication-list" |
5+
relLangURL }}'>Publications</a>
86
</div>
97
<div>
10-
<a class="mr-4" href="{{ `search` | relURL }}"><i class="fas fa-search"></i></i></a>
8+
<a class="mr-4" href='{{ "search" | relLangURL }}'><i class="fas fa-search"></i></a>
119
<i class="fas fa-sun theme-toggle text-blue-500 hover:text-blue-700 dark:text-yellow-300 dark:hover:text-yellow-500 cursor-pointer text-lg mr-9 sm:mr-0"
1210
onclick="lightDark(this)"></i>
1311
<a class="no-underline p-2 rounded hover:bg-gray-200 dark:hover:bg-gray-800 cursor-pointer"
@@ -17,7 +15,7 @@
1715

1816
<script>
1917
const lightDark = (el) => {
20-
let html = document.querySelector("html");
18+
const html = document.querySelector("html");
2119
if (html.classList.contains("dark")) {
2220
html.classList.remove("dark");
2321
el.classList.add("fa-moon");
@@ -40,13 +38,11 @@
4038
const currentLanguage = getCurrentLanguage();
4139

4240
if (currentLanguage === "ja") {
43-
// Remove "/ja" from the path to redirect to the English page
4441
basePath = basePath.replace(/^\/ja/, "");
4542
} else {
46-
// Add "/ja" to the path to redirect to the Japanese page
43+
basePath = basePath.replace(/^\/en/, "");
4744
basePath = "/ja" + basePath;
4845
}
49-
5046
window.location.href = basePath;
5147
}
5248

0 commit comments

Comments
 (0)