File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 6
6
setRequestLocale ,
7
7
} from "next-intl/server"
8
8
9
+ import { SlugPageParams } from "@/lib/types"
10
+
9
11
import I18nProvider from "@/components/I18nProvider"
10
12
import mdComponents from "@/components/MdComponents"
11
13
@@ -27,7 +29,7 @@ const loadData = dataLoader([["gfissues", fetchGFIs]])
27
29
export default async function Page ( {
28
30
params,
29
31
} : {
30
- params : Promise < { locale : string ; slug : string [ ] } >
32
+ params : Promise < SlugPageParams >
31
33
} ) {
32
34
const { locale, slug : slugArray } = await params
33
35
@@ -109,7 +111,7 @@ export async function generateStaticParams() {
109
111
export async function generateMetadata ( {
110
112
params,
111
113
} : {
112
- params : Promise < { locale : string ; slug : string [ ] } >
114
+ params : Promise < SlugPageParams >
113
115
} ) {
114
116
const { locale, slug } = await params
115
117
Original file line number Diff line number Diff line change @@ -1028,3 +1028,11 @@ export interface ITutorial {
1028
1028
lang : string
1029
1029
isExternal : boolean
1030
1030
}
1031
+
1032
+ export type PageParams = {
1033
+ locale : string
1034
+ }
1035
+
1036
+ export type SlugPageParams = PageParams & {
1037
+ slug : string [ ]
1038
+ }
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { extname, join } from "path"
5
5
import matter from "gray-matter"
6
6
import readingTime from "reading-time"
7
7
8
- import type { Frontmatter , ITutorial , Skill } from "@/lib/types"
8
+ import type { Frontmatter , ITutorial , Skill , SlugPageParams } from "@/lib/types"
9
9
10
10
import { dateToString } from "@/lib/utils/date"
11
11
@@ -100,3 +100,12 @@ export const getTutorialsData = (locale: string): ITutorial[] => {
100
100
101
101
return tutorialData
102
102
}
103
+
104
+ export const checkPathValidity = (
105
+ validPaths : SlugPageParams [ ] ,
106
+ { locale, slug : slugArray } : SlugPageParams
107
+ ) : boolean =>
108
+ validPaths . some (
109
+ ( path ) =>
110
+ path . locale === locale && path . slug . join ( "/" ) === slugArray . join ( "/" )
111
+ )
You can’t perform that action at this time.
0 commit comments