@@ -19,15 +19,6 @@ export type CodeExample = {
19
19
export type Product = {
20
20
title : string
21
21
href : string
22
- categories : Record <
23
- string ,
24
- {
25
- href : string
26
- title : string
27
- standalone ?: boolean
28
- articles ?: Record < string , { href : string ; title : string ; shortTitle ?: string } >
29
- }
30
- >
31
22
}
32
23
33
24
export type ProductLandingContextT = {
@@ -79,14 +70,7 @@ export const useProductLandingContext = (): ProductLandingContextT => {
79
70
}
80
71
81
72
export const getProductLandingContextFromRequest = ( req : any ) : ProductLandingContextT => {
82
- const {
83
- currentCategory,
84
- currentPath,
85
- siteTree,
86
- currentLanguage,
87
- currentVersion,
88
- currentProduct,
89
- } = req . context
73
+ const productTree = req . context . currentProductTree
90
74
return {
91
75
...pick ( req . context . page , [
92
76
'title' ,
@@ -97,14 +81,13 @@ export const getProductLandingContextFromRequest = (req: any): ProductLandingCon
97
81
'product_video' ,
98
82
'changelog' ,
99
83
] ) ,
100
- product : JSON . parse (
101
- JSON . stringify ( siteTree [ currentLanguage ] [ currentVersion ] . products [ currentProduct ] )
102
- ) ,
103
- whatsNewChangelog : req . context . whatsNewChangelog ,
104
- changelogUrl : req . context . changelogUrl ,
105
-
84
+ product : {
85
+ href : productTree . href ,
86
+ title : productTree . renderedShortTitle || productTree . renderedFullTitle ,
87
+ } ,
88
+ whatsNewChangelog : req . context . whatsNewChangelog || [ ] ,
89
+ changelogUrl : req . context . changelogUrl || [ ] ,
106
90
productCodeExamples : req . context . productCodeExamples || [ ] ,
107
-
108
91
productCommunityExamples : req . context . productCommunityExamples || [ ] ,
109
92
110
93
productUserExamples : ( req . context . productUserExamples || [ ] ) . map (
@@ -114,11 +97,13 @@ export const getProductLandingContextFromRequest = (req: any): ProductLandingCon
114
97
} )
115
98
) ,
116
99
117
- introLinks : Object . fromEntries (
118
- Object . entries ( req . context . page . introLinks || { } ) . filter ( ( [ key , val ] ) => ! ! val )
119
- ) ,
100
+ introLinks : {
101
+ quickstart : productTree . page . introLinks . quickstart ,
102
+ reference : productTree . page . introLinks . reference ,
103
+ overview : productTree . page . introLinks . overview ,
104
+ } ,
120
105
121
- guideCards : ( req . context . featuredLinks . guideCards || [ ] ) . map ( ( link : any ) => {
106
+ guideCards : ( req . context . featuredLinks ? ( req . context . featuredLinks . guideCards || [ ] ) : [ ] ) . map ( ( link : any ) => {
122
107
return {
123
108
href : link . href ,
124
109
title : link . title ,
@@ -127,14 +112,14 @@ export const getProductLandingContextFromRequest = (req: any): ProductLandingCon
127
112
}
128
113
} ) ,
129
114
130
- featuredArticles : Object . entries ( req . context . featuredLinks )
115
+ featuredArticles : Object . entries ( req . context . featuredLinks || [ ] )
131
116
. filter ( ( [ key ] ) => {
132
117
return key === 'guides' || key === 'popular'
133
118
} )
134
119
. map ( ( [ key , links ] : any ) => {
135
120
return {
136
121
label : req . context . site . data . ui . toc [ key ] ,
137
- viewAllHref : key === 'guides' && ! currentCategory ? `${ currentPath } /${ key } ` : '' ,
122
+ viewAllHref : key === 'guides' && ! req . context . currentCategory ? `${ req . context . currentPath } /${ key } ` : '' ,
138
123
articles : links . map ( ( link : any ) => {
139
124
return {
140
125
hideIntro : key === 'popular' ,
@@ -145,6 +130,7 @@ export const getProductLandingContextFromRequest = (req: any): ProductLandingCon
145
130
}
146
131
} ) ,
147
132
}
148
- } ) ,
133
+ }
134
+ ) ,
149
135
}
150
136
}
0 commit comments