From eb55bfe905a6d927575c860a86a88b895cf84b23 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Thu, 20 Feb 2025 17:50:34 +0100 Subject: [PATCH] fix: properly build static pages this time --- src/app/[locale]/[...not-found]/page.tsx | 3 +- src/app/[locale]/pages/[slug]/page.tsx | 39 +++++++++++++++--------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/app/[locale]/[...not-found]/page.tsx b/src/app/[locale]/[...not-found]/page.tsx index 0d721e6..5f6aab4 100644 --- a/src/app/[locale]/[...not-found]/page.tsx +++ b/src/app/[locale]/[...not-found]/page.tsx @@ -1,5 +1,6 @@ -import { notFound } from "next/navigation" +import { notFound } from "next/navigation"; export default function NotFoundDummy() { + console.log("Global catch-all 404 page"); notFound() } diff --git a/src/app/[locale]/pages/[slug]/page.tsx b/src/app/[locale]/pages/[slug]/page.tsx index d6ab030..15ffbfc 100644 --- a/src/app/[locale]/pages/[slug]/page.tsx +++ b/src/app/[locale]/pages/[slug]/page.tsx @@ -1,34 +1,43 @@ -import { getLocale, Lang } from "@/i18n/locales" -import { notFound } from "next/navigation" +import { getLocale, Lang } from "@/i18n/locales"; +import { notFound } from "next/navigation"; export default async function Page({ params, }: { - params: Promise<{ slug: string, locale: Lang }> + params: Promise<{ slug: string; locale: Lang }>; }) { - const { slug, locale } = await params - const currentLocale = getLocale(locale) + const { slug, locale } = await params; + const currentLocale = getLocale(locale); - const isReallyProperSlug = /^[a-zA-Z0-9_-]+$/.test(slug) + const isReallyProperSlug = /^[a-zA-Z0-9_-]+$/.test(slug); if (!isReallyProperSlug) { - notFound() + notFound(); } try { - const path = `@/pages/${currentLocale}/${slug}.mdx` - const pagemodule = await import(path) - const Post = pagemodule.default + console.log("Resolving path: ", `@/pages/${currentLocale}/${slug}.mdx`); + const pagemodule = await import(`@/pages/${currentLocale}/${slug}.mdx`); + const Post = pagemodule.default; - return + return ; } catch (error) { - console.log(error) - notFound() + console.log(error); + notFound(); } } export function generateStaticParams() { - return [{ slug: 'privacy' }] + return [ + { + locale: "pl", + slug: "privacy", + }, + { + locale: "en", + slug: "privacy", + }, + ]; } -export const dynamicParams = false +export const dynamicParams = false;