@@ -72,16 +72,111 @@ export const getRequiredNamespacesForPage = (
7272const getRequiredNamespacesForPath = ( relativePath : string ) => {
7373 const path = url . addSlashes ( relativePath )
7474
75- let primaryNamespace : string | undefined // the primary namespace for the page
75+ const primaryNamespace = getPrimaryNamespaceForPath ( path ) // the primary namespace for the page
7676 let requiredNamespaces : string [ ] = [ ] // any additional namespaces required for the page
7777
78+ if ( path === "/" ) {
79+ requiredNamespaces = [ ...requiredNamespaces , "page-10-year-anniversary" ]
80+ }
81+
82+ if ( path . startsWith ( "/energy-consumption/" ) ) {
83+ requiredNamespaces = [ ...requiredNamespaces , "page-about" ]
84+ }
85+
86+ if ( path . startsWith ( "/glossary/" ) ) {
87+ requiredNamespaces = [ ...requiredNamespaces , "glossary" ]
88+ }
89+
90+ if ( path . startsWith ( "/developers/docs/scaling/" ) ) {
91+ requiredNamespaces = [ ...requiredNamespaces , "page-layer-2" ]
92+ }
93+
94+ if ( path . startsWith ( "/roadmap/vision/" ) ) {
95+ requiredNamespaces = [
96+ ...requiredNamespaces ,
97+ "page-upgrades-index" ,
98+ "page-roadmap-vision" ,
99+ ]
100+ }
101+
102+ if ( path . startsWith ( "/gas/" ) ) {
103+ requiredNamespaces = [ ...requiredNamespaces , "page-gas" , "page-community" ]
104+ }
105+
106+ if ( path . endsWith ( "/wallets/find-wallet/" ) ) {
107+ requiredNamespaces = [ ...requiredNamespaces , "page-wallets" , "table" ]
108+ }
109+
110+ if ( path . startsWith ( "/layer-2/networks/" ) ) {
111+ requiredNamespaces = [ ...requiredNamespaces , "table" ]
112+ }
113+
114+ if ( path . startsWith ( "/start/" ) ) {
115+ requiredNamespaces = [ ...requiredNamespaces ]
116+ }
117+
118+ if ( path . startsWith ( "/10years/" ) ) {
119+ requiredNamespaces = [ ...requiredNamespaces , "page-10-year-anniversary" ]
120+ }
121+
122+ // Glossary tooltips
123+ if (
124+ path . startsWith ( "/apps/" ) ||
125+ path . startsWith ( "/layer-2/" ) ||
126+ path . startsWith ( "/layer-2/learn/" ) ||
127+ path . startsWith ( "/get-eth/" ) ||
128+ path . startsWith ( "/stablecoins/" ) ||
129+ path . startsWith ( "/staking/" ) ||
130+ path . startsWith ( "/run-a-node/" ) ||
131+ path . startsWith ( "/what-is-ethereum/" ) ||
132+ path . startsWith ( "/eth/" ) ||
133+ path . startsWith ( "/wallets/" ) ||
134+ path . startsWith ( "/gas/" )
135+ ) {
136+ requiredNamespaces = [ ...requiredNamespaces , "glossary-tooltip" ]
137+ }
138+
139+ // Quizzes
140+ // Note: Add any URL paths that have quizzes here
141+ if (
142+ path . startsWith ( "/defi/" ) ||
143+ path . startsWith ( "/eth/" ) ||
144+ path . startsWith ( "/gas/" ) ||
145+ path . startsWith ( "/layer-2/" ) ||
146+ path . startsWith ( "/layer-2/learn/" ) ||
147+ path . startsWith ( "/nft/" ) ||
148+ path . startsWith ( "/quizzes/" ) ||
149+ path . startsWith ( "/roadmap/merge/" ) ||
150+ path . startsWith ( "/roadmap/scaling/" ) ||
151+ path . startsWith ( "/run-a-node/" ) ||
152+ path . startsWith ( "/security/" ) ||
153+ path . startsWith ( "/smart-contracts/" ) ||
154+ path . startsWith ( "/stablecoins/" ) ||
155+ path . startsWith ( "/staking/solo/" ) ||
156+ path . startsWith ( "/wallets/" ) ||
157+ path . startsWith ( "/web3/" ) ||
158+ path . startsWith ( "/what-is-ethereum/" )
159+ ) {
160+ requiredNamespaces = [ ...requiredNamespaces , "learn-quizzes" ]
161+ }
162+
163+ // Ensures that the primary namespace is always the first item in the array
164+ return primaryNamespace
165+ ? [ primaryNamespace , ...requiredNamespaces ]
166+ : [ ...requiredNamespaces ]
167+ }
168+
169+ export const getPrimaryNamespaceForPath = ( relativePath : string ) => {
170+ const path = url . addSlashes ( relativePath )
171+
172+ let primaryNamespace : string | undefined
173+
78174 if ( path === "/assets/" ) {
79175 primaryNamespace = "page-assets"
80176 }
81177
82178 if ( path === "/" ) {
83179 primaryNamespace = "page-index"
84- requiredNamespaces = [ ...requiredNamespaces , "page-10-year-anniversary" ]
85180 }
86181
87182 if ( path === "/collectibles/" ) {
@@ -106,17 +201,12 @@ const getRequiredNamespacesForPath = (relativePath: string) => {
106201
107202 if ( path . startsWith ( "/energy-consumption/" ) ) {
108203 primaryNamespace = "page-energy-consumption"
109- requiredNamespaces = [ ...requiredNamespaces , "page-about" ]
110204 }
111205
112206 if ( path . startsWith ( "/eth/" ) ) {
113207 primaryNamespace = "page-eth"
114208 }
115209
116- if ( path . startsWith ( "/glossary/" ) ) {
117- requiredNamespaces = [ ...requiredNamespaces , "glossary" ]
118- }
119-
120210 if ( path . startsWith ( "/ethereum-forks/" ) ) {
121211 primaryNamespace = "page-history"
122212 }
@@ -157,25 +247,12 @@ const getRequiredNamespacesForPath = (relativePath: string) => {
157247 primaryNamespace = "page-developers-tutorials"
158248 }
159249
160- if ( path . startsWith ( "/developers/docs/scaling/" ) ) {
161- requiredNamespaces = [ ...requiredNamespaces , "page-layer-2" ]
162- }
163-
164250 if ( path === "/get-eth/" ) {
165251 primaryNamespace = "page-get-eth"
166252 }
167253
168- if ( path . startsWith ( "/roadmap/vision/" ) ) {
169- requiredNamespaces = [
170- ...requiredNamespaces ,
171- "page-upgrades-index" ,
172- "page-roadmap-vision" ,
173- ]
174- }
175-
176254 if ( path . startsWith ( "/gas/" ) ) {
177255 primaryNamespace = "page-gas"
178- requiredNamespaces = [ ...requiredNamespaces , "page-gas" , "page-community" ]
179256 }
180257
181258 if ( path . startsWith ( "/what-is-ethereum/" ) ) {
@@ -196,7 +273,6 @@ const getRequiredNamespacesForPath = (relativePath: string) => {
196273
197274 if ( path . endsWith ( "/wallets/find-wallet/" ) ) {
198275 primaryNamespace = "page-wallets-find-wallet"
199- requiredNamespaces = [ ...requiredNamespaces , "page-wallets" , "table" ]
200276 }
201277
202278 // TODO: Remove this when the page is translated
@@ -210,7 +286,6 @@ const getRequiredNamespacesForPath = (relativePath: string) => {
210286
211287 if ( path . startsWith ( "/layer-2/networks/" ) ) {
212288 primaryNamespace = "page-layer-2-networks"
213- requiredNamespaces = [ ...requiredNamespaces , "table" ]
214289 }
215290
216291 if ( path . startsWith ( "/roadmap/" ) ) {
@@ -219,62 +294,13 @@ const getRequiredNamespacesForPath = (relativePath: string) => {
219294
220295 if ( path . startsWith ( "/start/" ) ) {
221296 primaryNamespace = "page-start"
222- requiredNamespaces = [ ...requiredNamespaces ]
223297 }
224298
225299 if ( path . startsWith ( "/contributing/translation-program/translatathon/" ) ) {
226300 primaryNamespace = "page-translatathon"
227301 }
228302
229- if ( path . startsWith ( "/10years/" ) ) {
230- requiredNamespaces = [ ...requiredNamespaces , "page-10-year-anniversary" ]
231- }
232-
233- // Glossary tooltips
234- if (
235- path . startsWith ( "/apps/" ) ||
236- path . startsWith ( "/layer-2/" ) ||
237- path . startsWith ( "/layer-2/learn/" ) ||
238- path . startsWith ( "/get-eth/" ) ||
239- path . startsWith ( "/stablecoins/" ) ||
240- path . startsWith ( "/staking/" ) ||
241- path . startsWith ( "/run-a-node/" ) ||
242- path . startsWith ( "/what-is-ethereum/" ) ||
243- path . startsWith ( "/eth/" ) ||
244- path . startsWith ( "/wallets/" ) ||
245- path . startsWith ( "/gas/" )
246- ) {
247- requiredNamespaces = [ ...requiredNamespaces , "glossary-tooltip" ]
248- }
249-
250- // Quizzes
251- // Note: Add any URL paths that have quizzes here
252- if (
253- path . startsWith ( "/defi/" ) ||
254- path . startsWith ( "/eth/" ) ||
255- path . startsWith ( "/gas/" ) ||
256- path . startsWith ( "/layer-2/" ) ||
257- path . startsWith ( "/layer-2/learn/" ) ||
258- path . startsWith ( "/nft/" ) ||
259- path . startsWith ( "/quizzes/" ) ||
260- path . startsWith ( "/roadmap/merge/" ) ||
261- path . startsWith ( "/roadmap/scaling/" ) ||
262- path . startsWith ( "/run-a-node/" ) ||
263- path . startsWith ( "/security/" ) ||
264- path . startsWith ( "/smart-contracts/" ) ||
265- path . startsWith ( "/stablecoins/" ) ||
266- path . startsWith ( "/staking/solo/" ) ||
267- path . startsWith ( "/wallets/" ) ||
268- path . startsWith ( "/web3/" ) ||
269- path . startsWith ( "/what-is-ethereum/" )
270- ) {
271- requiredNamespaces = [ ...requiredNamespaces , "learn-quizzes" ]
272- }
273-
274- // Ensures that the primary namespace is always the first item in the array
275303 return primaryNamespace
276- ? [ primaryNamespace , ...requiredNamespaces ]
277- : [ ...requiredNamespaces ]
278304}
279305
280306const getRequiredNamespacesForLayout = ( layout ?: string ) => {
0 commit comments