(slug: string, lang: string)
| 241 | }; |
| 242 | |
| 243 | export async function getLocalizedPanelSidebar(slug: string, lang: string) { |
| 244 | const sidebar = [...PANEL_ITEMS, ...PANEL_FRAMEWORK_ITEMS]; |
| 245 | |
| 246 | const slugs = await getSlugs(); |
| 247 | |
| 248 | const localizedSidebars = sidebar.map(({ items, id }) => { |
| 249 | const sidebarItems = items.map((group) => { |
| 250 | const groupTitle = getTextLocalized(group, lang); |
| 251 | return { |
| 252 | title: groupTitle, |
| 253 | collapsed: group.collapsed, |
| 254 | items: group.items.map((item) => { |
| 255 | const itemTitle = getTextLocalized(item, lang); |
| 256 | |
| 257 | if (isExternal(item)) { |
| 258 | return { |
| 259 | title: itemTitle, |
| 260 | link: item.link, |
| 261 | }; |
| 262 | } |
| 263 | |
| 264 | const link = createLink(item, lang); |
| 265 | |
| 266 | // Translated page exists |
| 267 | if (slugs.has(link.toLowerCase())) { |
| 268 | return { |
| 269 | title: itemTitle, |
| 270 | link, |
| 271 | }; |
| 272 | } |
| 273 | |
| 274 | // If original page exists |
| 275 | const originalLink = createLink(item, SITE.defaultLanguage); |
| 276 | if (slugs.has(originalLink.toLowerCase())) { |
| 277 | return { |
| 278 | title: `${itemTitle}`, |
| 279 | link, |
| 280 | isFallback: true, |
| 281 | }; |
| 282 | } |
| 283 | |
| 284 | // If no original page exists, may be link is wrong? |
| 285 | return { |
| 286 | title: `${itemTitle} (404)`, |
| 287 | link: item.link, |
| 288 | }; |
| 289 | }), |
| 290 | }; |
| 291 | }); |
| 292 | |
| 293 | return { |
| 294 | sidebarItems, |
| 295 | panelId: id, |
| 296 | }; |
| 297 | }); |
| 298 | |
| 299 | return localizedSidebars; |
| 300 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…