diff --git a/docs/.vitepress/api/gh-icon/[...data].get.ts b/docs/.vitepress/api/gh-icon/[...data].get.ts index 8b4abb4c7..70b413516 100644 --- a/docs/.vitepress/api/gh-icon/[...data].get.ts +++ b/docs/.vitepress/api/gh-icon/[...data].get.ts @@ -17,11 +17,14 @@ export default eventHandler((event) => { const children = []; - // If the icon already exists, it uses the existing icon as the backdrop. - // If the icon does not exist but an icon exists that starts with the same group name, that icon - // is used as the backdrop - const backdropName = - name in iconNodes ? name : name.split('-')[0] in iconNodes ? name.split('-')[0] : null; + // Finds the longest matching icon to be use as the backdrop. + // For `square-dashed-bottom-code` it suggests `square-dashed-bottom-code`. + // For `square-dashed-bottom-i-dont-exist` it suggests `square-dashed-bottom`. + const backdropName = name + .split('-') + .map((_, idx, arr) => arr.slice(0, idx + 1).join('-')) + .reverse() + .find((groupName) => groupName in iconNodes); if (backdropName) { const iconNode = iconNodes[backdropName];