import classNames from "classnames"; import { useTranslation } from "react-i18next"; import { useAppSelector } from "../stores"; import useViewStore from "../stores/v1/view"; import Icon from "./Icon"; const Navigator = () => { const { t } = useTranslation(); const viewStore = useViewStore(); const { shortcutList } = useAppSelector((state) => state.shortcut); const tags = shortcutList.map((shortcut) => shortcut.tags).flat(); const currentTab = viewStore.filter.tab || `tab:all`; const sortedTagMap = sortTags(tags); return (
{Array.from(sortedTagMap.keys()).map((tag) => ( ))}
); }; const sortTags = (tags: string[]): Map => { const map = new Map(); for (const tag of tags) { const count = map.get(tag) || 0; map.set(tag, count + 1); } const sortedMap = new Map([...map.entries()].sort((a, b) => b[1] - a[1])); return sortedMap; }; export default Navigator;