fix(koja): default to fa (no browser locale guess); guard null discoverProfile

Koja auto-detected locale from the browser Accept-Language (en for many Persian users); set localeDetection:false so locale-less URLs default to fa. Also guarded cafe.discoverProfile across the cafe page, cafe card, and JSON-LD — a café without a discover profile crashed the page (500). The cafe page now resolves the café first and notFound()s an unknown slug before fetching menu/reviews.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-02 01:51:50 +03:30
parent a83edf7667
commit e839db7331
4 changed files with 27 additions and 10 deletions
+4 -3
View File
@@ -11,7 +11,8 @@ interface Props {
export function CafeCard({ cafe, locale, href }: Props) {
const isFa = locale === "fa";
const name = isFa ? cafe.name : (cafe.name);
const priceTier = cafe.discoverProfile.priceTier;
const priceTier = cafe.discoverProfile?.priceTier ?? null;
const themes = cafe.discoverProfile?.themes ?? [];
const priceLabel = priceTier ? (PRICE_TIER_LABELS[priceTier]?.[isFa ? "fa" : "en"] ?? priceTier) : null;
return (
@@ -72,9 +73,9 @@ export function CafeCard({ cafe, locale, href }: Props) {
)}
{/* Tags */}
{cafe.discoverProfile.themes.length > 0 && (
{themes.length > 0 && (
<div className="mt-2 flex flex-wrap gap-1">
{cafe.discoverProfile.themes.slice(0, 3).map((tag) => (
{themes.slice(0, 3).map((tag) => (
<span
key={tag}
className="rounded-full bg-brand-50 px-2 py-0.5 text-[10px] font-medium text-brand-700"
+2 -2
View File
@@ -46,11 +46,11 @@ export function CafeJsonLd({ cafe, locale, baseUrl }: Props) {
worstRating: "1",
},
} : {}),
...(cafe.discoverProfile.themes.length ? {
...(cafe.discoverProfile?.themes?.length ? {
servesCuisine: cafe.discoverProfile.themes,
} : {}),
priceRange: (() => {
const tier = cafe.discoverProfile.priceTier;
const tier = cafe.discoverProfile?.priceTier;
if (tier === "budget") return "﷼";
if (tier === "moderate") return "﷼﷼";
if (tier === "upscale") return "﷼﷼﷼";