--- import { moreLocales, themeConfig } from '@/config' import { getNextGlobalLangPath, getNextSupportedLangPath } from '@/i18n/path' import { isPostPage, isTagPage } from '@/utils/page' interface Props { supportedLangs: string[] } const { light: { background: lightMode }, dark: { background: darkMode } } = themeConfig.color const { supportedLangs } = Astro.props 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) // Choose a language switch list according to the page type const nextUrl = useSupportedLangs ? getNextSupportedLangPath(currentPath, supportedLangs) // Switch between supported languages in post/tag page : getNextGlobalLangPath(currentPath) // Switch between all languages in other pages ---
{showLanguageSwitcher && ( )}