chore: update code comment

This commit is contained in:
radishzzz 2025-03-17 00:28:22 +00:00
parent 1492ae07d2
commit 93c2fbb5b3
5 changed files with 36 additions and 23 deletions

View file

@ -24,7 +24,7 @@ const year = Number(startYear) === currentYear
className,
]}
>
<!-- Only show on desktop -->
<!-- Desktop widget -->
<div class="mb-11.5 ml-1.5 hidden gap-7 lg:flex">
<ThemeToggle />
<LanguageSwitcher supportedLangs={supportedLangs} />

View file

@ -1,4 +1,5 @@
---
import { moreLocales } from '@/config'
import { getNextGlobalLangPath, getNextSupportedLangPath } from '@/i18n/path'
import { isPostPage, isTagPage } from '@/utils/page'
@ -11,6 +12,9 @@ const currentPath = Astro.url.pathname
const isPost = isPostPage(currentPath)
const isTag = isTagPage(currentPath)
// Check if there are other languages to switch
const showLanguageSwitcher = moreLocales.length > 0
// Check if only the supported language switch list is used
const useSupportedLangs = isPost || (isTag && supportedLangs.length > 0)
@ -20,18 +24,20 @@ const nextUrl = useSupportedLangs
: getNextGlobalLangPath(currentPath) // Switch between all languages
---
<a
href={nextUrl}
class="aspect-square w-4 c-secondary active:scale-90 hover:c-primary"
aria-label="Switch website language"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
aria-hidden="true"
class="h-full w-full"
fill="currentColor"
{showLanguageSwitcher && (
<a
href={nextUrl}
class="aspect-square w-4 c-secondary active:scale-90 hover:c-primary"
aria-label="Switch website language"
>
<path d="M19 21 12.3 2h-1L4.7 21l-2.5.2v.8h6.3v-.8L5.7 21l2-5.9h7.5l2 5.9-3.3.2v.8h7.9v-.8zM8 14.3l3.4-10.1 3.5 10.1z" />
</svg>
</a>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
aria-hidden="true"
class="h-full w-full"
fill="currentColor"
>
<path d="M19 21 12.3 2h-1L4.7 21l-2.5.2v.8h6.3v-.8L5.7 21l2-5.9h7.5l2 5.9-3.3.2v.8h7.9v-.8zM8 14.3l3.4-10.1 3.5 10.1z" />
</svg>
</a>
)}