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:
@@ -70,16 +70,29 @@ export default async function CafePage({
|
||||
const t = await getTranslations({ locale, namespace: "cafe" });
|
||||
const isFa = locale === "fa";
|
||||
|
||||
const [cafe, menu, reviews] = await Promise.all([
|
||||
getCafe(slug),
|
||||
// Resolve the café first so an unknown slug 404s cleanly instead of doing
|
||||
// (and potentially erroring on) the menu/review fetches.
|
||||
const cafe = await getCafe(slug);
|
||||
if (!cafe) notFound();
|
||||
|
||||
const [menu, reviews] = await Promise.all([
|
||||
getCafeMenu(slug),
|
||||
getCafeReviews(slug),
|
||||
]);
|
||||
|
||||
if (!cafe) notFound();
|
||||
|
||||
const name = isFa ? cafe.name : (cafe.nameEn ?? cafe.name);
|
||||
const profile = cafe.discoverProfile;
|
||||
// discoverProfile may be absent for cafés that never filled it in — fall back
|
||||
// to an empty profile so the page renders instead of throwing a 500.
|
||||
const profile = cafe.discoverProfile ?? {
|
||||
themes: [],
|
||||
size: null,
|
||||
floors: null,
|
||||
vibes: [],
|
||||
occasions: [],
|
||||
spaceFeatures: [],
|
||||
noiseLevel: null,
|
||||
priceTier: null,
|
||||
};
|
||||
const priceTier = profile.priceTier;
|
||||
|
||||
// Similar cafes
|
||||
|
||||
Reference in New Issue
Block a user