mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 11:41:17 +02:00
refactor: optimize website performance and layout
- Replace ScrollButton with BackToTop component - Improve theme toggle and scrollbar event handling - Update layout and index page styling - Optimize client:load and client:idle directives - Remove deprecated Heti addon plugin
This commit is contained in:
parent
14f53a979a
commit
47951152d1
13 changed files with 164 additions and 559 deletions
|
@ -80,7 +80,7 @@ function getCurrentTheme() {
|
|||
return document.documentElement.classList.contains('dark')
|
||||
}
|
||||
|
||||
function updateThemeColor(isDark) {
|
||||
function updateMetaTheme(isDark) {
|
||||
const metaThemeColor = document.querySelector('meta[name="theme-color"]')
|
||||
if (metaThemeColor) {
|
||||
metaThemeColor.setAttribute('content', isDark ? darkMode : lightMode)
|
||||
|
@ -89,7 +89,7 @@ function updateThemeColor(isDark) {
|
|||
|
||||
function syncTheme() {
|
||||
const isDark = getCurrentTheme()
|
||||
updateThemeColor(isDark)
|
||||
updateMetaTheme(isDark)
|
||||
}
|
||||
|
||||
function initTheme() {
|
||||
|
@ -105,7 +105,7 @@ function initTheme() {
|
|||
|
||||
const isDark = theme === 'dark'
|
||||
document.documentElement.classList.toggle('dark', isDark)
|
||||
updateThemeColor(isDark)
|
||||
updateMetaTheme(isDark)
|
||||
}
|
||||
|
||||
initTheme()
|
||||
|
@ -113,7 +113,7 @@ initTheme()
|
|||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
||||
if (!localStorage.getItem('theme')) {
|
||||
document.documentElement.classList.toggle('dark', e.matches)
|
||||
updateThemeColor(e.matches)
|
||||
updateMetaTheme(e.matches)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue