Skip to content

Commit

Permalink
fix: handle non-existing resources for unknown locale
Browse files Browse the repository at this point in the history
  • Loading branch information
babslgam committed Jan 7, 2025
1 parent 296a197 commit 7dc950f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/(app)/[locale]/(index)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { cn } from "@acdh-oeaw/style-variants";
import type { Entry } from "@keystatic/core/reader";
import { ArrowRightIcon } from "lucide-react";
import type { Metadata, ResolvingMetadata } from "next";
import { notFound } from "next/navigation";
import { getTranslations, setRequestLocale } from "next-intl/server";
import type { ReactNode } from "react";

Expand Down Expand Up @@ -49,16 +50,19 @@ export default async function IndexPage(props: Readonly<IndexPageProps>): Promis

const { locale } = params;
setRequestLocale(locale);

const page = await createSingletonResource("index-page", locale).read();
const { hero, main } = page.data;

return (
<MainContent className="layout-grid content-start">
<HeroSection {...hero} />
<FeaturesSection {...main} locale={locale} />
</MainContent>
);
try {
const page = await createSingletonResource("index-page", locale).read();
const { hero, main } = page.data;

return (
<MainContent className="layout-grid content-start">
<HeroSection {...hero} />
<FeaturesSection {...main} locale={locale} />
</MainContent>
);
} catch {
return notFound();
}
}

function HeroSection(props: Readonly<HeroSectionProps>): ReactNode {
Expand Down

0 comments on commit 7dc950f

Please sign in to comment.