@@ -165,6 +165,17 @@ function getPageTitle(page) {
165
165
return title;
166
166
}
167
167
168
+ async function smartLinkWithBadges (url , content ) {
169
+ let aPage = await wiki .getPage (url);
170
+ if (! aPage .title && env .locale !== ' en-US' ) {
171
+ const originalUrl = url .replace (` /${ env .locale } /` , " /en-US/" );
172
+ aPage = await wiki .getPage (originalUrl);
173
+ }
174
+ const link = web .smartLink (url, null , content, APIHref, null , " APIRef" );
175
+ const badges = (await page .badges (aPage)).join (" " );
176
+ return link + badges;
177
+ }
178
+
168
179
async function buildSublist (pages , title ) {
169
180
var result = ' <li class="toggle"><details open><summary>' + title + ' </summary><ol>' ;
170
181
@@ -185,8 +196,7 @@ async function buildSublist(pages, title) {
185
196
if (slug == aPage .slug ) {
186
197
result += ` <em><code>${ title} </code> ${ pageBadges} </em>`
187
198
} else {
188
- result += web .smartLink (url, null , ` <code>${ title} </code>` , APIHref, null , " APIRef" );
189
- result += pageBadges;
199
+ result += await smartLinkWithBadges (url, ` <code>${ title} </code>` );
190
200
}
191
201
192
202
if (rtlLocales .indexOf (locale) != - 1 ) {
@@ -201,13 +211,13 @@ async function buildSublist(pages, title) {
201
211
return result;
202
212
}
203
213
204
- function buildIFList (interfaces , title ) {
205
- var result = ' <li class="toggle"><details open><summary>' + title + ' </summary><ol>' ;
214
+ async function buildIFList (interfaces , title ) {
215
+ let result = ' <li class="toggle"><details open><summary>' + title + ' </summary><ol>' ;
206
216
207
217
for (var i = 0 ; i < interfaces .length ; i++ ) {
208
218
var url = APIHref + ' /' + interfaces[i].replace (' ()' , ' ' ).replace (' .' , ' /' );
209
219
if (! url .endsWith (slug)) {
210
- result += ` <li>${ web . smartLink (url, null , ` <code>${ interfaces[i]} </code>` , APIHref, null , " APIRef " )} </li>` ;
220
+ result += ` <li>${ await smartLinkWithBadges (url, ` <code>${ interfaces[i]} </code>` )} </li>` ;
211
221
}
212
222
}
213
223
@@ -219,10 +229,10 @@ function buildIFList(interfaces, title) {
219
229
// output
220
230
output = ' <section id="Quick_links" data-macro="APIRef"><ol>' ;
221
231
if (group && webAPIGroups[0 ][group] && webAPIGroups[0 ][group].overview ) {
222
- output += ` <li class="section">${ web . smartLink (APIHref + ' /' + webAPIGroups[0 ][group].overview [0 ].replace (/ / g , ' _' ), null , webAPIGroups[0 ][group].overview [0 ], APIHref, null , " APIRef " )} </li>` ;
232
+ output += ` <li class="section">${ await smartLinkWithBadges (APIHref + ' /' + webAPIGroups[0 ][group].overview [0 ].replace (/ / g , ' _' ), webAPIGroups[0 ][group].overview [0 ])} </li>` ;
223
233
}
224
234
225
- output += ` <li class="section">${ web . smartLink (APIHref + ' /' + mainIF, null , ` <code>${ mainIF} </code>` , APIHref, null , " APIRef " )} </li>` ;
235
+ output += ` <li class="section">${ await smartLinkWithBadges (APIHref + ' /' + mainIF, ` <code>${ mainIF} </code>` )} </li>` ;
226
236
227
237
if (ctors .length > 0 ) {
228
238
output += await buildSublist (ctors, text[' Constructor' ]);
@@ -243,14 +253,14 @@ if (events.length > 0) {
243
253
output += await buildSublist (events, text[' Events' ]);
244
254
}
245
255
if (inh .length > 0 ) {
246
- output += buildIFList (inheritedIF, text[' Inheritance' ]);
256
+ output += await buildIFList (inheritedIF, text[' Inheritance' ]);
247
257
}
248
258
if (implementedBy .length > 0 ) {
249
- output += buildIFList (implementedBy, text[' Implemented_by' ]);
259
+ output += await buildIFList (implementedBy, text[' Implemented_by' ]);
250
260
}
251
261
252
262
if (related .length > 0 ) {
253
- output += buildIFList (related, text[' Related' ]);
263
+ output += await buildIFList (related, text[' Related' ]);
254
264
}
255
265
256
266
output += ' </ol></section>' ;
0 commit comments