File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
app/(desktop)/[lng]/@blog/(.)/blog/[...catchAll] Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { GetBlogPostBySlug } from "@/data-provider/contentful/provider/blog-post-provider" ;
2
2
import { permanentRedirect , notFound } from "next/navigation" ;
3
3
import { revalidatePath } from "next/cache" ;
4
+ import { isValidLocale } from "@/helper/localization" ;
4
5
5
6
export default async function DefaultRedirect ( {
6
7
params,
7
8
} : {
8
9
params : { catchAll : string ; lng : string } ;
9
10
} ) {
10
- const post = await GetBlogPostBySlug ( params . catchAll , params . lng ) ;
11
+ let slug = Array . isArray ( params . catchAll )
12
+ ? params . catchAll [ 0 ]
13
+ : params . catchAll ;
11
14
15
+ if ( slug === null || ! isValidLocale ( params . lng ) ) notFound ( ) ;
16
+
17
+ const post = await GetBlogPostBySlug ( slug , params . lng ) ;
12
18
if ( post === null ) notFound ( ) ;
13
19
14
20
revalidatePath ( `/${ params . lng } /blog/${ params . catchAll } ` ) ;
You can’t perform that action at this time.
0 commit comments