mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-17 12:01:33 +02:00
refactor: enhance LanguageSwitcher and PhotoSwipe initialization
- Simplified LanguageSwitcher logic for better readability and performance. - Updated PhotoSwipe initialization to clean up existing instances before creating a new one, ensuring smoother transitions. - Changed event listener for PhotoSwipe to trigger on page load, improving responsiveness. - Revised theme configuration description and updated site URL for clarity.
This commit is contained in:
parent
bca8b9b1cf
commit
ee35006f7c
3 changed files with 11 additions and 13 deletions
|
@ -35,11 +35,9 @@ document.addEventListener('astro:page-load', () => {
|
|||
const firstSegment = segments[0] || ''
|
||||
// Check if first segment is a valid language code
|
||||
const currentLang = langs.includes(firstSegment) ? firstSegment : ''
|
||||
|
||||
// Get next language in rotation (empty string means default locale)
|
||||
const currentIndex = langs.indexOf(currentLang)
|
||||
const nextLang = langs[(currentIndex + 1) % langs.length]
|
||||
|
||||
const newPath = buildNewPath(currentLang, nextLang, segments, pathname) || '/'
|
||||
window.location.href = `${newPath}${search}${hash}`
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue