mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 03:32:51 +02:00
37 lines
1.1 KiB
Text
37 lines
1.1 KiB
Text
---
|
|
import { getNextLangUrl, getNextSupportedLangUrl } from '@/i18n/path'
|
|
import { isPostPage, isTagPage } from '@/utils/page'
|
|
|
|
interface Props {
|
|
supportedLangs: string[]
|
|
}
|
|
|
|
const { supportedLangs } = Astro.props
|
|
const currentPath = Astro.url.pathname
|
|
const isPost = isPostPage(currentPath)
|
|
const isTag = isTagPage(currentPath)
|
|
|
|
// Check if only the supported language switch list is used
|
|
const useSupportedLangs = isPost || (isTag && supportedLangs.length > 0)
|
|
|
|
// Choose a language switch list according to the page type
|
|
const nextUrl = useSupportedLangs
|
|
? getNextSupportedLangUrl(currentPath, supportedLangs) // Switch between supported languages
|
|
: getNextLangUrl(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"
|
|
>
|
|
<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>
|