refactor(theme): simplify icon handling to support only emojis for now

This commit is contained in:
Johannes Liermann 2025-12-02 17:45:06 +01:00
parent 84ff66d137
commit 65bfdac23d

View File

@ -115,25 +115,8 @@ function CardCategory({item}: {item: PropSidebarItemCategory}): ReactNode {
function CardLink({item}: {item: PropSidebarItemLink}): ReactNode {
const defaultIcon = isInternalUrl(item.href) ? '📄' : '🔗';
let customIcon;
// If the icon is a string, it can be an simple string icon or a PNG/JPEG image, render accordingly
if (typeof item.icon === 'string') {
if (
/^data:image\/(?:png|jpe?g)/i.test(item.icon) ||
/\.(?:png|jpe?g)/i.test(item.icon)
) {
customIcon = (
<img
src={item.icon}
alt={`${item.label}-icon`}
style={{maxWidth: '24px', maxHeight: '24px'}}
/>
);
} else {
customIcon = item.icon;
}
}
const customIcon =
typeof item.icon === 'string' && item.icon.length <= 2 ? item.icon : null;
const icon = customIcon || defaultIcon;
const doc = useDocById(item.docId ?? undefined);