Skip to content

Commit 4cede6f

Browse files
committed
Fixed blog catchAll redirect
1 parent 46a3f29 commit 4cede6f

File tree

1 file changed

+7
-1
lines changed
  • app/(desktop)/[lng]/@blog/(.)/blog/[...catchAll]

1 file changed

+7
-1
lines changed

app/(desktop)/[lng]/@blog/(.)/blog/[...catchAll]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import { GetBlogPostBySlug } from "@/data-provider/contentful/provider/blog-post-provider";
22
import { permanentRedirect, notFound } from "next/navigation";
33
import { revalidatePath } from "next/cache";
4+
import { isValidLocale } from "@/helper/localization";
45

56
export default async function DefaultRedirect({
67
params,
78
}: {
89
params: { catchAll: string; lng: string };
910
}) {
10-
const post = await GetBlogPostBySlug(params.catchAll, params.lng);
11+
let slug = Array.isArray(params.catchAll)
12+
? params.catchAll[0]
13+
: params.catchAll;
1114

15+
if (slug === null || !isValidLocale(params.lng)) notFound();
16+
17+
const post = await GetBlogPostBySlug(slug, params.lng);
1218
if (post === null) notFound();
1319

1420
revalidatePath(`/${params.lng}/blog/${params.catchAll}`);

0 commit comments

Comments
 (0)