1
1
import { useEffect , useMemo , useState } from "react"
2
- import { GetStaticProps } from "next"
2
+ import { GetStaticProps , InferGetServerSidePropsType } from "next"
3
+ import { SSRConfig } from "next-i18next"
3
4
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
4
5
import { useTranslation } from "react-i18next"
5
- import { FaGithub , FaYandexInternational } from "react-icons/fa"
6
+ import { FaGithub } from "react-icons/fa"
6
7
import { Badge , Box , chakra , Flex , forwardRef , Heading , useToken } from "@chakra-ui/react"
7
8
8
9
import { Lang } from "@/lib/types"
@@ -19,6 +20,7 @@ import Translation from "@/components/Translation"
19
20
import { getSkillTranslationId , Skill } from "@/components/TutorialMetadata"
20
21
import TutorialTags from "@/components/TutorialTags"
21
22
23
+ import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
22
24
import { trackCustomEvent } from "@/lib/utils/matomo"
23
25
import { getTutorialsData } from "@/lib/utils/md"
24
26
import { getLocaleTimestamp , INVALID_DATETIME } from "@/lib/utils/time"
@@ -58,21 +60,23 @@ const FilterTag = forwardRef<{ isActive: boolean; name: string }, "button">(
58
60
}
59
61
)
60
62
61
- export const getStaticProps = async (
63
+ export const getStaticProps = ( async (
62
64
context
63
65
) => {
64
66
const { locale } = context
65
67
// load i18n required namespaces for the given page
66
68
const requiredNamespaces = getRequiredNamespacesForPage ( '/developers/tutorials' )
69
+ const lastDeployDate = getLastDeployDate ( )
67
70
68
71
return {
69
72
props : {
70
73
...( await serverSideTranslations ( locale ! , requiredNamespaces ) ) ,
71
74
internalTutorials : getTutorialsData ( locale ! ) ,
72
75
locale,
76
+ lastDeployDate
73
77
} ,
74
78
}
75
- }
79
+ } ) satisfies GetStaticProps < SSRConfig >
76
80
77
81
export interface IExternalTutorial {
78
82
url : string
@@ -109,15 +113,15 @@ const published = (locale: string, published: string) => {
109
113
) : null
110
114
}
111
115
112
- const TutorialPage = ( { internalTutorials, locale } : InferGetServerSidePropsType < typeof getServerSideProps > ) => {
116
+ const TutorialPage = ( { internalTutorials, locale } : InferGetServerSidePropsType < typeof getStaticProps > ) => {
113
117
const tableBoxShadow = useToken ( "colors" , "tableBoxShadow" )
114
118
const cardBoxShadow = useToken ( "colors" , "cardBoxShadow" )
115
119
const filteredTutorialsByLang = useMemo (
116
120
( ) =>
117
121
filterTutorialsByLang (
118
122
internalTutorials ,
119
123
externalTutorials ,
120
- locale
124
+ locale as Lang
121
125
) ,
122
126
[ internalTutorials , locale ]
123
127
)
@@ -438,22 +442,22 @@ const TutorialPage = ({ internalTutorials, locale }: InferGetServerSidePropsType
438
442
< Text color = "text200" fontSize = "sm" textTransform = "uppercase" >
439
443
< Emoji text = ":writing_hand:" fontSize = "sm" mr = { 2 } />
440
444
{ tutorial . author } •
441
- { published ( locale , tutorial . published ?? "" ) }
445
+ { published ( locale ! , tutorial . published ?? "" ) }
442
446
{ tutorial . timeToRead && (
443
447
< >
444
448
{ " " }
445
449
•
446
450
< Emoji text = ":stopwatch:" fontSize = "sm" ml = { 2 } mr = { 2 } />
447
451
{ tutorial . timeToRead } { " " }
448
- < Translation id = "page-tutorial-read-time" />
452
+ < Translation id = "page-developers-tutorials:page- tutorial-read-time" />
449
453
</ >
450
454
) }
451
455
{ tutorial . isExternal && (
452
456
< >
453
457
{ " " }
454
458
•< Emoji text = ":link:" fontSize = "sm" ml = { 2 } mr = { 2 } />
455
459
< Box as = "span" color = "primary.base" cursor = "pointer" >
456
- < Translation id = "page-tutorial-external-link" />
460
+ < Translation id = "page-developers-tutorials:page- tutorial-external-link" />
457
461
</ Box >
458
462
</ >
459
463
) }
0 commit comments