Fix request locale resolution in site pages
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-15 08:20:39 +01:00
parent c18128c965
commit 288e4b37d7
10 changed files with 80 additions and 81 deletions
+9 -10
View File
@@ -1,5 +1,5 @@
import type { Metadata } from "next";
import { getTranslations } from "next-intl/server";
import { getLocale, getTranslations } from "next-intl/server";
import { notFound } from "next/navigation";
import { Container } from "@/components/layout/container";
@@ -7,7 +7,7 @@ import { PageHero } from "@/components/layout/page-hero";
import { PortfolioProjectDetail } from "@/components/site/portfolio-project-detail";
import { getSiteSettings } from "@/lib/app-config";
import { buildLocalizedMetadata } from "@/lib/metadata";
import { FALLBACK_LOCALE, resolveLocale } from "@/lib/locale";
import { resolveLocale } from "@/lib/locale";
import {
getLocalizedValue,
getPublishedPortfolioProjectBySlug,
@@ -23,8 +23,9 @@ type PortfolioItemPageProps = {
export const dynamic = "force-dynamic";
export async function generateMetadata({ params }: PortfolioItemPageProps): Promise<Metadata> {
const { locale, slug } = await params;
const localeKey = resolveLocale(locale, FALLBACK_LOCALE);
const { slug } = await params;
const siteSettings = await getSiteSettings();
const localeKey = resolveLocale(await getLocale().catch(() => siteSettings.defaultLocale), siteSettings.defaultLocale);
const item = await getPublishedPortfolioProjectBySlug(slug);
if (!item) {
@@ -47,18 +48,16 @@ export async function generateMetadata({ params }: PortfolioItemPageProps): Prom
export default async function PortfolioItemPage({
params,
}: PortfolioItemPageProps) {
const { locale, slug } = await params;
const localeKey = resolveLocale(locale, FALLBACK_LOCALE);
const { slug } = await params;
const siteSettings = await getSiteSettings();
const localeKey = resolveLocale(await getLocale().catch(() => siteSettings.defaultLocale), siteSettings.defaultLocale);
const item = await getPublishedPortfolioProjectBySlug(slug);
if (!item) {
notFound();
}
const [t, siteSettings] = await Promise.all([
getTranslations({ locale: localeKey, namespace: "portfolioDetail" }),
getSiteSettings(),
]);
const t = await getTranslations({ locale: localeKey, namespace: "portfolioDetail" });
return (
<>