From 2390820e41617702b2ca93e3e1360ddd6aa4516b Mon Sep 17 00:00:00 2001 From: bunker-admin Date: Tue, 3 Mar 2026 11:08:45 -0700 Subject: [PATCH] Fix MkDocs header nav rendering broken icons for unmapped Ant Design icons ScheduleOutlined was missing from the ANT_ICON_TO_MATERIAL mapping in header-builder.service.ts, causing Material Icons to render raw text characters ("S", "O") instead of a clock icon for the Shifts nav item. Added the missing mapping and a toMaterialIcon() fallback that converts any unmapped Ant Design icon name to snake_case Material Icons format. Bunker Admin --- api/src/modules/docs/header-builder.service.ts | 15 ++++++++++++++- mkdocs/docs/overrides/main.html | 8 ++------ mkdocs/site/overrides/main.html | 8 ++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/api/src/modules/docs/header-builder.service.ts b/api/src/modules/docs/header-builder.service.ts index f5a1e8ac..30bcc970 100644 --- a/api/src/modules/docs/header-builder.service.ts +++ b/api/src/modules/docs/header-builder.service.ts @@ -50,6 +50,7 @@ const ANT_ICON_TO_MATERIAL: Record = { HomeOutlined: 'home', SendOutlined: 'send', EnvironmentOutlined: 'place', + ScheduleOutlined: 'schedule', CalendarOutlined: 'event', PlayCircleOutlined: 'play_circle', HeartOutlined: 'favorite_border', @@ -60,6 +61,18 @@ const ANT_ICON_TO_MATERIAL: Record = { BookOutlined: 'menu_book', }; +/** + * Convert an Ant Design icon name to a Material Icons ligature name. + * Uses the explicit mapping first, then falls back to stripping the + * Outlined/Filled/TwoTone suffix and converting PascalCase to snake_case. + */ +function toMaterialIcon(antIcon: string): string { + if (ANT_ICON_TO_MATERIAL[antIcon]) return ANT_ICON_TO_MATERIAL[antIcon]; + // Fallback: strip suffix, convert PascalCase → snake_case + const base = antIcon.replace(/(Outlined|Filled|TwoTone)$/, ''); + return base.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase(); +} + interface NavConfigItem { id: string; label: string; @@ -415,7 +428,7 @@ class HeaderBuilderService { id: item.id, label: item.label, path: resolvedPath, - icon: ANT_ICON_TO_MATERIAL[item.icon] || item.icon, + icon: toMaterialIcon(item.icon), enabled: true, order: item.order, type: item.type, diff --git a/mkdocs/docs/overrides/main.html b/mkdocs/docs/overrides/main.html index 914f93fd..9a9ed57b 100644 --- a/mkdocs/docs/overrides/main.html +++ b/mkdocs/docs/overrides/main.html @@ -13,11 +13,9 @@