fix: make FuzzySearch generic to support typed items

- Add SearchableItem base interface for minimum required fields
- Make FuzzySearch class generic with type parameter
- Update all page scripts to use typed FuzzySearch instances
- Fix type casting in calculateScore method
This commit is contained in:
Aaron Powell
2026-01-29 09:56:20 +11:00
parent 63fb276a6c
commit d46210b2de
8 changed files with 27 additions and 20 deletions

View File

@@ -2,13 +2,14 @@
* Collections page functionality
*/
import { createChoices, getChoicesValues, type Choices } from '../choices';
import { FuzzySearch, type SearchItem } from '../search';
import { FuzzySearch } from '../search';
import { fetchData, debounce, escapeHtml, getGitHubUrl } from '../utils';
import { setupModal, openFileModal } from '../modal';
interface Collection {
id: string;
name: string;
title: string;
description?: string;
path: string;
tags?: string[];
@@ -25,7 +26,7 @@ interface CollectionsData {
const resourceType = 'collection';
let allItems: Collection[] = [];
let search = new FuzzySearch();
let search = new FuzzySearch<Collection>();
let tagSelect: Choices;
let currentFilters = {
tags: [] as string[],