martials.no/src/utils/linking.ts

25 lines
536 B
TypeScript
Raw Normal View History

import type { AvailableLanguageTag } from "@/paraglide/runtime.js"
type AbsolutePathname = `/${string}`
// TODO what?
// https://inlang.com/m/iljlwzfs/paraglide-astro-i18n
const pathnames: Record<AbsolutePathname,
Record<AvailableLanguageTag, AbsolutePathname>
> = {
"/contact-me": {
nb: "/contact-me",
en: "/en/contact-me"
}
}
export function localizePathname(
pathname: AbsolutePathname,
locale: AvailableLanguageTag
) {
if (pathnames[pathname]) {
return pathnames[pathname][locale]
}
return pathname
}