18 lines
537 B
TypeScript
18 lines
537 B
TypeScript
import { locales, defaultLocale } from "@/lib/dictionaries";
|
|
|
|
export const SITE_URL = "https://ksan.dev";
|
|
|
|
// Canonical + hreflang alternates for a page, e.g. localeAlternates("sr", "/about").
|
|
export function localeAlternates(locale: string, path: string = "") {
|
|
const languages: Record<string, string> = {};
|
|
for (const l of locales) {
|
|
languages[l] = `${SITE_URL}/${l}${path}`;
|
|
}
|
|
languages["x-default"] = `${SITE_URL}/${defaultLocale}${path}`;
|
|
|
|
return {
|
|
canonical: `${SITE_URL}/${locale}${path}`,
|
|
languages,
|
|
};
|
|
}
|