Skip to content

Commit

Permalink
fix: reject non-matching locales
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgoff committed Oct 10, 2024
1 parent 7c19862 commit 7dada33
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import I18NextClientProvider from "@/contexts/i18next";
import { AuthenticationContextProvider } from "@/contexts/Authentication";
import PageWrapper from "@/components/organisms/PageWrapper";
import RootScripts from "./scripts";
import { notFound } from "next/navigation";

const GOOGLE_APP_ID = process.env.NEXT_PUBLIC_GOOGLE_APP_ID || "";

export async function generateMetadata({
params: { locale },
}: LocaleProps): Promise<Metadata> {
if (!languages.includes(locale)) {
notFound();
}

const { siteInfo: metadata } = await getGlobalData(locale);
const { siteTitle, siteDescription, siteImage, language } = metadata;
const { url, width, height, altText: alt } = siteImage[0];
Expand Down Expand Up @@ -53,6 +58,10 @@ const LocaleLayout: FunctionComponent<PropsWithChildren<LocaleProps>> = async ({
params: { locale },
children,
}) => {
if (!languages.includes(locale)) {
notFound();
}

return (
<html lang={locale}>
<head></head>
Expand Down

0 comments on commit 7dada33

Please sign in to comment.