diff --git a/src/components/shortcuts.jsx b/src/components/shortcuts.jsx index afefc822..b466014b 100644 --- a/src/components/shortcuts.jsx +++ b/src/components/shortcuts.jsx @@ -23,26 +23,29 @@ function Shortcuts() { const menuRef = useRef(); - const formattedShortcuts = shortcuts.map((pin, i) => { - const { type, ...data } = pin; - let { path, title, icon } = SHORTCUTS_META[type]; + const formattedShortcuts = shortcuts + .map((pin, i) => { + const { type, ...data } = pin; + if (!SHORTCUTS_META[type]) return null; + let { path, title, icon } = SHORTCUTS_META[type]; - if (typeof path === 'function') { - path = path(data, i); - } - if (typeof title === 'function') { - title = title(data); - } - if (typeof icon === 'function') { - icon = icon(data); - } + if (typeof path === 'function') { + path = path(data, i); + } + if (typeof title === 'function') { + title = title(data); + } + if (typeof icon === 'function') { + icon = icon(data); + } - return { - path, - title, - icon, - }; - }); + return { + path, + title, + icon, + }; + }) + .filter(Boolean); const navigate = useNavigate(); useHotkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9'], (e, handler) => {