This commit is contained in:
+6
-6
@@ -1,6 +1,6 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
import { routing } from "../i18n/routing";
|
||||
import { appLocales } from "../i18n/routing";
|
||||
import {
|
||||
PAGE_TITLE_TOKEN,
|
||||
SITE_NAME_TOKEN,
|
||||
@@ -22,9 +22,9 @@ function toAbsoluteUrl(pathname: string): string {
|
||||
return new URL(pathname, getSiteUrl()).toString();
|
||||
}
|
||||
|
||||
export function buildLocaleAlternates(pathname: string, defaultLocale = routing.defaultLocale) {
|
||||
export function buildLocaleAlternates(pathname: string, defaultLocale: AppLocale) {
|
||||
const languages = Object.fromEntries(
|
||||
routing.locales.map((locale) => [locale, toAbsoluteUrl(getLocalizedPathWithDefault(locale, pathname, defaultLocale))]),
|
||||
appLocales.map((locale) => [locale, toAbsoluteUrl(getLocalizedPathWithDefault(locale, pathname, defaultLocale))]),
|
||||
) as Record<AppLocale, string>;
|
||||
|
||||
return {
|
||||
@@ -120,8 +120,8 @@ export async function buildLocalizedMetadata({
|
||||
description,
|
||||
applyTitleTemplate,
|
||||
}: LocalizedMetadataInput): Promise<Metadata> {
|
||||
const localeKey = resolveLocale(locale);
|
||||
const [settings, bindings] = await Promise.all([getSiteSettings(), getSiteSettingsMediaBindings()]);
|
||||
const localeKey = resolveLocale(locale, settings.defaultLocale);
|
||||
|
||||
return buildLocalizedMetadataFromConfig({
|
||||
settings,
|
||||
@@ -152,7 +152,7 @@ export function buildLocalizedMetadataFromConfig(input: {
|
||||
description,
|
||||
applyTitleTemplate = true,
|
||||
} = input;
|
||||
const localeKey = resolveLocale(locale);
|
||||
const localeKey = resolveLocale(locale, settings.defaultLocale);
|
||||
const localeSettings = settings.locales[localeKey];
|
||||
const resolvedDescription = description?.trim() || localeSettings.siteDescription;
|
||||
const resolvedTitle = applyTitleTemplate
|
||||
@@ -167,7 +167,7 @@ export function buildLocalizedMetadataFromConfig(input: {
|
||||
openGraph: {
|
||||
title: resolvedTitle,
|
||||
description: resolvedDescription,
|
||||
url: toAbsoluteUrl(getLocalizedPath(localeKey, pathname)),
|
||||
url: toAbsoluteUrl(getLocalizedPath(localeKey, pathname, settings.defaultLocale)),
|
||||
siteName: localeSettings.siteName,
|
||||
locale: localeKey,
|
||||
type: "website",
|
||||
|
||||
Reference in New Issue
Block a user