diff options
author | Junle Qian <calebqian.uiuc@gmail.com> | 2021-03-06 18:45:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-06 18:45:06 +0300 |
commit | 36689965a873bbf0853f1a98857e1ab8338cc860 (patch) | |
tree | c8e621a6531b78da3f108ee9398f406e8c6ee2d8 | |
parent | 4d319a1c3594e8efe16b47b2c0ced5716c0237e5 (diff) |
refactor: add translations to color scheme list (#76)
* Add archive layout
* Correct posts range
Correct posts range in custom theme's archive layout
so that doc pages don't get accidentally archived in posts archive
layout.
* Force HTTPS
* Add Chinese support for light switch
* Normalize Archive page CSS style
* Separate archive content from article div
* Remove archive layout for feature exclusion
* refactor: change translations
Co-authored-by: Wang Chucheng <me@wangchucheng.com>
-rw-r--r-- | assets/js/eureka.js | 7 | ||||
-rw-r--r-- | i18n/en.yaml | 8 | ||||
-rw-r--r-- | i18n/zh.yaml | 8 | ||||
-rw-r--r-- | layouts/partials/header.html | 10 |
4 files changed, 23 insertions, 10 deletions
diff --git a/assets/js/eureka.js b/assets/js/eureka.js index 469a34d..9fa18a1 100644 --- a/assets/js/eureka.js +++ b/assets/js/eureka.js @@ -127,13 +127,14 @@ function getcolorscheme() { for (let target of targets) { target.addEventListener('click', () => { - let icon = switchMode(target.innerHTML) + let targetName = target.getAttribute("name") + let icon = switchMode(targetName) let old_icon = element.firstElementChild.getAttribute("data-icon") element.firstElementChild.setAttribute("data-icon", icon) element.firstElementChild.classList.remove('fa-' + old_icon) element.firstElementChild.classList.add('fa-' + icon) - localStorage.setItem("lightDarkMode", target.innerHTML) + localStorage.setItem("lightDarkMode", targetName) targetDiv.classList.toggle('hidden') screen.classList.toggle('hidden') @@ -260,4 +261,4 @@ function switchDocVersion() { element.lastElementChild.classList.toggle('fa-caret-right'); element.lastElementChild.classList.toggle('fa-caret-down'); }) -}
\ No newline at end of file +} diff --git a/i18n/en.yaml b/i18n/en.yaml index c96facb..5046dc7 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -17,4 +17,10 @@ recent: onThisPage: other: On This Page editThisPage: - other: Edit this page
\ No newline at end of file + other: Edit this page +light: + other: Light +dark: + other: Dark +auto: + other: Auto diff --git a/i18n/zh.yaml b/i18n/zh.yaml index 91ffc50..dd87eb8 100644 --- a/i18n/zh.yaml +++ b/i18n/zh.yaml @@ -17,4 +17,10 @@ recent: onThisPage: other: 本页内容 editThisPage: - other: 编辑本页
\ No newline at end of file + other: 编辑本页 +light: + other: 浅色 +dark: + other: 深色 +auto: + other: 自动 diff --git a/layouts/partials/header.html b/layouts/partials/header.html index eaf53d5..c782397 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -45,9 +45,9 @@ </div> <div class="absolute flex flex-col left-0 md:left-auto right-auto md:right-0 hidden bg-secondary-bg w-48 rounded py-2 border border-tertiary-bg cursor-pointer z-40" id='lightDarkOptions'> - <span class="px-4 py-1 hover:text-eureka">Light</span> - <span class="px-4 py-1 hover:text-eureka">Dark</span> - <span class="px-4 py-1 hover:text-eureka">Auto</span> + <span class="px-4 py-1 hover:text-eureka" name="Light">{{i18n "light"}}</span> + <span class="px-4 py-1 hover:text-eureka" name="Dark">{{i18n "dark"}}</span> + <span class="px-4 py-1 hover:text-eureka" name="Auto">{{i18n "auto"}}</span> </div> </div> @@ -118,7 +118,7 @@ element.firstElementChild.classList.add('fa-moon') } {{- end }} - + document.addEventListener('DOMContentLoaded', () => { getcolorscheme(); switchBurger(); @@ -126,4 +126,4 @@ switchLanguage() {{- end }} }); -</script>
\ No newline at end of file +</script> |