1
1
import { merge } from "lodash"
2
2
import { GetStaticProps } from "next"
3
- import { SSRConfig , useTranslation } from "next-i18next"
3
+ import { useTranslation } from "next-i18next"
4
4
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
5
5
import {
6
6
Badge ,
@@ -15,7 +15,11 @@ import {
15
15
UnorderedList ,
16
16
} from "@chakra-ui/react"
17
17
18
- import type { CommonHeroProps , TranslationKey } from "@/lib/types"
18
+ import type {
19
+ BasePageProps ,
20
+ CommonHeroProps ,
21
+ TranslationKey ,
22
+ } from "@/lib/types"
19
23
20
24
import { ButtonLink } from "@/components/Buttons"
21
25
import Card from "@/components/Card"
@@ -33,6 +37,7 @@ import PageMetadata from "@/components/PageMetadata"
33
37
import { StandaloneQuizWidget } from "@/components/Quiz/QuizWidget"
34
38
import Translation from "@/components/Translation"
35
39
40
+ import { existsNamespace } from "@/lib/utils/existsNamespace"
36
41
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
37
42
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
38
43
@@ -104,23 +109,21 @@ const Layer2CardGrid = (props) => (
104
109
/>
105
110
)
106
111
107
- type Props = SSRConfig & {
108
- lastDeployDate : string
109
- }
112
+ export const getStaticProps = ( async ( { locale } ) => {
113
+ const lastDeployDate = getLastDeployDate ( )
110
114
111
- export const getStaticProps = ( async ( context ) => {
112
- const { locale } = context
113
- // load i18n required namespaces for the given page
114
115
const requiredNamespaces = getRequiredNamespacesForPage ( "/layer-2" )
115
- const lastDeployDate = getLastDeployDate ( )
116
+
117
+ const contentNotTranslated = ! existsNamespace ( locale ! , requiredNamespaces [ 2 ] )
116
118
117
119
return {
118
120
props : {
119
121
...( await serverSideTranslations ( locale ! , requiredNamespaces ) ) ,
122
+ contentNotTranslated,
120
123
lastDeployDate,
121
124
} ,
122
125
}
123
- } ) satisfies GetStaticProps < Props >
126
+ } ) satisfies GetStaticProps < BasePageProps >
124
127
125
128
const Layer2Page = ( ) => {
126
129
const { t } = useTranslation ( "page-layer-2" )
0 commit comments