From 1e9e9118775afc0938a46055aad19f43c3fc2f6c Mon Sep 17 00:00:00 2001 From: Ben Phelps Date: Wed, 11 Sep 2024 15:13:36 +0300 Subject: [PATCH] better handle the full selfh.st icon set --- src/components/resolvedicon.jsx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/resolvedicon.jsx b/src/components/resolvedicon.jsx index 141d88311..afbe31904 100644 --- a/src/components/resolvedicon.jsx +++ b/src/components/resolvedicon.jsx @@ -7,7 +7,6 @@ import { ThemeContext } from "utils/contexts/theme"; const iconSetURLs = { mdi: "https://cdn.jsdelivr.net/npm/@mdi/svg@latest/svg/", si: "https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/", - sh: "https://cdn.jsdelivr.net/gh/selfhst/icons@main/svg/", // or via GH's CDN https://icons.selfh.st/svg/ }; export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "logo" }) { @@ -36,6 +35,26 @@ export default function ResolvedIcon({ icon, width = 32, height = 32, alt = "log // check mdi- or si- prefixed icons const prefix = icon.split("-")[0]; + if (prefix === "sh") { + const iconName = icon.replace("sh-", "").replace(".svg", "").replace(".png", "").replace(".webp", ""); + const extension = icon.endsWith(".svg") ? "svg" : icon.endsWith(".webp") ? "webp" : "png"; + return ( + {alt} + ); + } + if (prefix in iconSetURLs) { // default to theme setting let iconName = icon.replace(`${prefix}-`, "").replace(".svg", "");