File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/pages/communities/[slug] Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import { fetchAllChallenges } from "@/store/services/communities/challenges";
12
12
import { NotFoundError } from "@/utilities/errors/NotFoundError" ;
13
13
import { fetchAllScoreboards } from "@/store/services/communities/scoreboard.service" ;
14
14
import { useTranslation } from "next-i18next" ;
15
+ import { fetchCommunities } from "@/services/community" ;
16
+ import { GetStaticPathsContext } from "next" ;
15
17
16
18
export default function Slug ( props : {
17
19
pageProps : {
@@ -41,7 +43,7 @@ Slug.getLayout = function (page: ReactElement) {
41
43
return < CommunityLayout > { page } </ CommunityLayout > ;
42
44
} ;
43
45
44
- export const getServerSideProps = wrapper . getServerSideProps ( ( store ) => async ( { params , locale } ) => {
46
+ export const getStaticProps = wrapper . getStaticProps ( ( store : any ) => async ( { locale , params } ) => {
45
47
try {
46
48
const slug = params ?. slug as string ;
47
49
@@ -59,10 +61,27 @@ export const getServerSideProps = wrapper.getServerSideProps((store) => async ({
59
61
scoreboard,
60
62
...translations ,
61
63
} ,
64
+
65
+ revalidate : 60 * 60 * 24 ,
62
66
} ;
63
67
} catch ( error ) {
64
68
return {
65
69
notFound : true ,
66
70
} ;
67
71
}
68
72
} ) ;
73
+
74
+ export const getStaticPaths = async ( context : GetStaticPathsContext ) => {
75
+ const locale = context . defaultLocale ;
76
+ const communities = await fetchCommunities ( { locale : locale ?? "en" } ) ;
77
+ const paths = communities . map ( ( community ) => ( {
78
+ params : {
79
+ slug : community . slug ,
80
+ } ,
81
+ } ) ) ;
82
+
83
+ return {
84
+ paths,
85
+ fallback : "blocking" ,
86
+ } ;
87
+ } ;
You can’t perform that action at this time.
0 commit comments