@@ -16,6 +16,7 @@ import InlineLink from "@/components/ui/Link"
16
16
import { dataLoader } from "@/lib/utils/data/dataLoader"
17
17
import { existsNamespace } from "@/lib/utils/existsNamespace"
18
18
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
19
+ import { networkMaturity } from "@/lib/utils/networkMaturity"
19
20
import { getLocaleTimestamp } from "@/lib/utils/time"
20
21
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
21
22
@@ -24,6 +25,7 @@ import { layer2Data, Rollups } from "@/data/networks/networks"
24
25
import { BASE_TIME_UNIT } from "@/lib/constants"
25
26
26
27
import { fetchGrowThePie } from "@/lib/api/fetchGrowThePie"
28
+ import { fetchL2beat } from "@/lib/api/fetchL2beat"
27
29
import HeroImage from "@/public/images/heroes/layer-2-hub-hero.jpg"
28
30
import EthereumLogo from "@/public/images/layer-2/ethereum.png"
29
31
import WalkingImage from "@/public/images/layer-2/layer-2-walking.png"
@@ -34,7 +36,10 @@ import ManDogCardImage from "@/public/images/man-and-dog-playing.png"
34
36
const REVALIDATE_TIME = BASE_TIME_UNIT * 24
35
37
36
38
const loadData = dataLoader (
37
- [ [ "growThePieData" , fetchGrowThePie ] ] ,
39
+ [
40
+ [ "growThePieData" , fetchGrowThePie ] ,
41
+ [ "l2beatData" , fetchL2beat ] ,
42
+ ] ,
38
43
REVALIDATE_TIME * 1000
39
44
)
40
45
@@ -49,14 +54,34 @@ export const getStaticProps = (async ({ locale }) => {
49
54
50
55
const contentNotTranslated = ! existsNamespace ( locale ! , requiredNamespaces [ 2 ] )
51
56
52
- const [ growThePieData ] = await loadData ( )
57
+ const [ growThePieData , l2beatData ] = await loadData ( )
58
+
59
+ const getRandomL2s = ( ) => {
60
+ let randomL2s = layer2Data . filter (
61
+ ( network ) =>
62
+ networkMaturity ( l2beatData . data . projects [ network . l2beatID ] ) === "robust"
63
+ )
64
+
65
+ if ( randomL2s . length === 0 ) {
66
+ randomL2s = layer2Data . filter (
67
+ ( network ) =>
68
+ networkMaturity ( l2beatData . data . projects [ network . l2beatID ] ) ===
69
+ "maturing"
70
+ )
71
+ }
72
+
73
+ return randomL2s . sort ( ( ) => 0.5 - Math . random ( ) ) . slice ( 0 , 3 )
74
+ }
53
75
54
76
const randomL2s = layer2Data . sort ( ( ) => 0.5 - Math . random ( ) ) . slice ( 0 , 9 )
55
77
78
+ const userRandomL2s = getRandomL2s ( )
79
+
56
80
return {
57
81
props : {
58
82
...( await serverSideTranslations ( locale ! , requiredNamespaces ) ) ,
59
83
randomL2s,
84
+ userRandomL2s,
60
85
contentNotTranslated,
61
86
lastDeployLocaleTimestamp,
62
87
locale,
@@ -67,10 +92,12 @@ export const getStaticProps = (async ({ locale }) => {
67
92
68
93
const Layer2Hub = ( {
69
94
randomL2s,
95
+ userRandomL2s,
70
96
growThePieData,
71
97
locale,
72
98
} : {
73
99
randomL2s : Rollups
100
+ userRandomL2s : Rollups
74
101
growThePieData : GrowThePieData
75
102
locale : Lang
76
103
} ) => {
@@ -385,7 +412,7 @@ const Layer2Hub = ({
385
412
< div id = "layer-2-cta" className = "w-full px-8 py-9" >
386
413
< div className = "mx-auto flex max-w-[640px] flex-col gap-6 rounded bg-main-gradient p-8" >
387
414
< div className = "flex flex-col gap-6" >
388
- { randomL2s . slice ( 0 , 3 ) . map ( ( l2 , idx ) => {
415
+ { userRandomL2s . map ( ( l2 , idx ) => {
389
416
return (
390
417
< div
391
418
key = { idx }
0 commit comments