diff --git a/bun.lockb b/bun.lockb index 8a534ae..518de3c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 35e9aed..4482f5e 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,14 @@ "@heroicons/react": "^2.0.18", "@tailwindcss/forms": "^0.5.6", "@tanstack/react-query": "^4.35.3", + "ramda": "^0.29.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-select": "^5.7.5", "react-window": "^1.8.9" }, "devDependencies": { + "@types/ramda": "^0.29.5", "@types/react": "^18.0.37", "@types/react-dom": "^18.0.11", "@types/react-window": "^1.8.6", diff --git a/src/TA.tsx b/src/TA.tsx index a9a939e..f45d19a 100644 --- a/src/TA.tsx +++ b/src/TA.tsx @@ -1,7 +1,8 @@ -import {ReactNode, useCallback} from "react"; +import {ReactNode, useCallback, useState} from "react"; import AsyncSelect from "react-select/async"; import {FixedSizeList as List} from "react-window"; import Select, {createFilter, MenuListProps} from "react-select"; +import * as R from 'ramda'; import {useQuery} from "@tanstack/react-query"; @@ -70,8 +71,12 @@ const TestSelect = (vendorOptions: any) => { } interface Option { - value: string, label: string, + value: string, + data: { + backlinks: unknown[] + aliases?: string[] + } } export function LargeSelect() { @@ -85,19 +90,23 @@ export function LargeSelect() { const response = await fetch("http://100.115.154.44:9002/metadata") const fullData: any[] = await response.json(); - return fullData.map(md => ({ - value: md.relativePath as string, - label: md.fileName as string - }) as Option); + return R.sortBy(v => -(v.data.backlinks?.length ?? 0), fullData.map(md => ({ + value: md.relativePath, + label: md.fileName, + data: md, + }) as Option)); }, }); + const [selected, setSelected] = useState