This commit is contained in:
parent
53883f4148
commit
eb55bfe905
|
|
@ -1,5 +1,6 @@
|
||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
export default function NotFoundDummy() {
|
export default function NotFoundDummy() {
|
||||||
|
console.log("Global catch-all 404 page");
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,43 @@
|
||||||
import { getLocale, Lang } from "@/i18n/locales"
|
import { getLocale, Lang } from "@/i18n/locales";
|
||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
params,
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: Promise<{ slug: string, locale: Lang }>
|
params: Promise<{ slug: string; locale: Lang }>;
|
||||||
}) {
|
}) {
|
||||||
const { slug, locale } = await params
|
const { slug, locale } = await params;
|
||||||
const currentLocale = getLocale(locale)
|
const currentLocale = getLocale(locale);
|
||||||
|
|
||||||
const isReallyProperSlug = /^[a-zA-Z0-9_-]+$/.test(slug)
|
const isReallyProperSlug = /^[a-zA-Z0-9_-]+$/.test(slug);
|
||||||
|
|
||||||
if (!isReallyProperSlug) {
|
if (!isReallyProperSlug) {
|
||||||
notFound()
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const path = `@/pages/${currentLocale}/${slug}.mdx`
|
console.log("Resolving path: ", `@/pages/${currentLocale}/${slug}.mdx`);
|
||||||
const pagemodule = await import(path)
|
const pagemodule = await import(`@/pages/${currentLocale}/${slug}.mdx`);
|
||||||
const Post = pagemodule.default
|
const Post = pagemodule.default;
|
||||||
|
|
||||||
return <Post />
|
return <Post />;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error);
|
||||||
notFound()
|
notFound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateStaticParams() {
|
export function generateStaticParams() {
|
||||||
return [{ slug: 'privacy' }]
|
return [
|
||||||
|
{
|
||||||
|
locale: "pl",
|
||||||
|
slug: "privacy",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
locale: "en",
|
||||||
|
slug: "privacy",
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dynamicParams = false
|
export const dynamicParams = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue