mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
fix(website): resolve TypeScript errors in samples.ts
- Remove SearchableRecipe interface that conflicted with SearchableItem - Use proper type casting for search results - Fix FuzzySearch generic type usage
This commit is contained in:
@@ -19,7 +19,7 @@ interface RecipeVariant {
|
|||||||
example: string | null;
|
example: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Recipe extends SearchableItem {
|
interface Recipe {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
@@ -49,7 +49,7 @@ interface SamplesData {
|
|||||||
|
|
||||||
// State
|
// State
|
||||||
let samplesData: SamplesData | null = null;
|
let samplesData: SamplesData | null = null;
|
||||||
let search: FuzzySearch<Recipe & { title: string; cookbookId: string }> | null = null;
|
let search: FuzzySearch<SearchableItem> | null = null;
|
||||||
let selectedLanguage: string | null = null;
|
let selectedLanguage: string | null = null;
|
||||||
let selectedTags: string[] = [];
|
let selectedTags: string[] = [];
|
||||||
let expandedRecipes: Set<string> = new Set();
|
let expandedRecipes: Set<string> = new Set();
|
||||||
@@ -73,7 +73,7 @@ export async function initSamplesPage(): Promise<void> {
|
|||||||
...recipe,
|
...recipe,
|
||||||
title: recipe.name,
|
title: recipe.name,
|
||||||
cookbookId: cookbook.id
|
cookbookId: cookbook.id
|
||||||
}))
|
} as SearchableItem & { cookbookId: string }))
|
||||||
);
|
);
|
||||||
search = new FuzzySearch(allRecipes);
|
search = new FuzzySearch(allRecipes);
|
||||||
|
|
||||||
@@ -212,14 +212,15 @@ function getFilteredRecipes(): { cookbook: Cookbook; recipe: Recipe; highlighted
|
|||||||
let results: { cookbook: Cookbook; recipe: Recipe; highlighted?: string }[] = [];
|
let results: { cookbook: Cookbook; recipe: Recipe; highlighted?: string }[] = [];
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
// Use fuzzy search
|
// Use fuzzy search - returns SearchableItem[] directly
|
||||||
const searchResults = search.search(query);
|
const searchResults = search.search(query);
|
||||||
results = searchResults.map(result => {
|
results = searchResults.map(item => {
|
||||||
const cookbook = samplesData!.cookbooks.find(c => c.id === result.item.cookbookId)!;
|
const recipe = item as SearchableItem & { cookbookId: string };
|
||||||
|
const cookbook = samplesData!.cookbooks.find(c => c.id === recipe.cookbookId)!;
|
||||||
return {
|
return {
|
||||||
cookbook,
|
cookbook,
|
||||||
recipe: result.item,
|
recipe: recipe as unknown as Recipe,
|
||||||
highlighted: search!.highlight(result.item.title, query)
|
highlighted: search!.highlight(recipe.title, query)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user