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
This commit is contained in:
@@ -50,6 +50,7 @@ const ANT_ICON_TO_MATERIAL: Record<string, string> = {
|
||||
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<string, string> = {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user