Fix runtime default locale resolution
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-15 06:02:27 +01:00
parent 9b8409a7d3
commit c18128c965
29 changed files with 330 additions and 108 deletions
@@ -9,6 +9,7 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { CardContent } from "@/components/ui/card";
import { getAdminAppPath } from "@/lib/admin-routing";
import { getSiteSettings } from "@/lib/app-config";
import { getLocalizedPath } from "@/lib/locale";
import { getLocalizedValue, type PortfolioCategoryView, type PortfolioProjectView } from "@/lib/portfolio";
@@ -28,11 +29,13 @@ const copy = {
empty: "Noch keine Projekte vorhanden.",
};
export function PortfolioProjectsOverview({
export async function PortfolioProjectsOverview({
categories,
projects,
selectedCategory,
}: PortfolioProjectsOverviewProps) {
const siteSettings = await getSiteSettings();
return (
<div className="space-y-6">
<div className="flex flex-col gap-4 xl:flex-row xl:items-end xl:justify-between">
@@ -102,7 +105,7 @@ export function PortfolioProjectsOverview({
<div className="flex flex-wrap gap-3">
<Button asChild variant="outline">
<Link
href={getLocalizedPath("de", `/portfolio/${project.slug}`)}
href={getLocalizedPath("de", `/portfolio/${project.slug}`, siteSettings.defaultLocale)}
target="_blank"
rel="noreferrer"
>
+2 -2
View File
@@ -17,7 +17,7 @@ const PENDING_TOAST_STORAGE_KEY = "mohfarawati-pending-toast";
type LocaleToggleProps = {
locale: string;
defaultLocale?: AppLocale;
defaultLocale: AppLocale;
className?: string;
showLabel?: boolean;
};
@@ -30,7 +30,7 @@ const localeChangedMessages: Record<AppLocale, string> = {
export function LocaleToggle({
locale,
defaultLocale = "de",
defaultLocale,
className,
showLabel = false,
}: LocaleToggleProps) {
@@ -7,6 +7,7 @@ import { cn } from "@/lib/utils";
type PortfolioCategoryFilterProps = {
locale: AppLocale;
defaultLocale: AppLocale;
categories: PortfolioCategoryView[];
allLabel: string;
activeCategorySlug?: string;
@@ -14,6 +15,7 @@ type PortfolioCategoryFilterProps = {
export function PortfolioCategoryFilter({
locale,
defaultLocale,
categories,
allLabel,
activeCategorySlug,
@@ -21,14 +23,14 @@ export function PortfolioCategoryFilter({
return (
<section className="flex flex-wrap gap-3">
<CategoryLink
href={getLocalizedPath(locale, "/portfolio")}
href={getLocalizedPath(locale, "/portfolio", defaultLocale)}
label={allLabel}
active={!activeCategorySlug}
/>
{categories.map((category) => (
<CategoryLink
key={category.id}
href={getLocalizedPath(locale, `/portfolio/category/${category.slug}`)}
href={getLocalizedPath(locale, `/portfolio/category/${category.slug}`, defaultLocale)}
label={getLocalizedValue(category.name, locale)}
active={activeCategorySlug === category.slug}
/>
+14 -7
View File
@@ -24,6 +24,7 @@ import {
type PortfolioProjectDetailProps = {
item: PortfolioProjectView;
locale: AppLocale;
defaultLocale: AppLocale;
t: (key: "back" | "preview" | "openLink" | "gallery" | "download") => string;
};
@@ -223,10 +224,12 @@ function BadgeCount({ count }: { count: number }) {
function ProjectHeader({
item,
locale,
defaultLocale,
t,
}: {
item: PortfolioProjectView;
locale: AppLocale;
defaultLocale: AppLocale;
t: PortfolioProjectDetailProps["t"];
}) {
return (
@@ -234,7 +237,7 @@ function ProjectHeader({
<AppCard level={3}>
<CardContent className="p-6 lg:p-10">
<Button asChild variant="ghost" className="h-auto px-0 py-0 text-sm">
<Link href={getLocalizedPath(locale, "/portfolio")}>{t("back")}</Link>
<Link href={getLocalizedPath(locale, "/portfolio", defaultLocale)}>{t("back")}</Link>
</Button>
<h1 className="mt-5 text-3xl font-semibold text-foreground sm:text-4xl lg:text-5xl">
@@ -267,11 +270,12 @@ function ProjectHeader({
function GridTemplate({
item,
locale,
defaultLocale,
t,
}: PortfolioProjectDetailProps) {
return (
<div className="space-y-6">
<ProjectHeader item={item} locale={locale} t={t} />
<ProjectHeader item={item} locale={locale} defaultLocale={defaultLocale} t={t} />
{item.coverImagePath ? (
<MotionFade delay={0.04}>
@@ -309,11 +313,12 @@ function GridTemplate({
function StoryTemplate({
item,
locale,
defaultLocale,
t,
}: PortfolioProjectDetailProps) {
return (
<div className="space-y-8">
<ProjectHeader item={item} locale={locale} t={t} />
<ProjectHeader item={item} locale={locale} defaultLocale={defaultLocale} t={t} />
{item.coverImagePath ? (
<MotionFade delay={0.04}>
@@ -356,6 +361,7 @@ function StoryTemplate({
function CaseStudyTemplate({
item,
locale,
defaultLocale,
t,
}: PortfolioProjectDetailProps) {
const [challenge, solution, outcome, ...restSections] = item.sections;
@@ -365,7 +371,7 @@ function CaseStudyTemplate({
return (
<div className="space-y-8">
<ProjectHeader item={item} locale={locale} t={t} />
<ProjectHeader item={item} locale={locale} defaultLocale={defaultLocale} t={t} />
<div className="grid gap-6 xl:grid-cols-[minmax(0,1.2fr)_420px]">
<div className="space-y-6">
@@ -441,17 +447,18 @@ function CaseStudyTemplate({
export function PortfolioProjectDetail({
item,
locale,
defaultLocale,
t,
}: PortfolioProjectDetailProps) {
const viewMode = resolvePortfolioProjectViewMode(item.viewMode);
if (viewMode === "STORY") {
return <StoryTemplate item={item} locale={locale} t={t} />;
return <StoryTemplate item={item} locale={locale} defaultLocale={defaultLocale} t={t} />;
}
if (viewMode === "CASE_STUDY") {
return <CaseStudyTemplate item={item} locale={locale} t={t} />;
return <CaseStudyTemplate item={item} locale={locale} defaultLocale={defaultLocale} t={t} />;
}
return <GridTemplate item={item} locale={locale} t={t} />;
return <GridTemplate item={item} locale={locale} defaultLocale={defaultLocale} t={t} />;
}
+3 -1
View File
@@ -9,6 +9,7 @@ import { getLocalizedValue, type PortfolioProjectView } from "@/lib/portfolio";
type PortfolioProjectGridProps = {
locale: AppLocale;
defaultLocale: AppLocale;
projects: PortfolioProjectView[];
emptyLabel: string;
openLabel: string;
@@ -16,6 +17,7 @@ type PortfolioProjectGridProps = {
export function PortfolioProjectGrid({
locale,
defaultLocale,
projects,
emptyLabel,
openLabel,
@@ -27,7 +29,7 @@ export function PortfolioProjectGrid({
<AppCard interactive>
<CardContent className="p-5">
<Link
href={getLocalizedPath(locale, `/portfolio/${item.slug}`)}
href={getLocalizedPath(locale, `/portfolio/${item.slug}`, defaultLocale)}
className="group block"
>
<div className="flex items-center justify-between gap-3">