MCPcopy Index your code
hub / github.com/github/awesome-copilot / initSamplesPage

Function initSamplesPage

website/src/scripts/pages/samples.ts:38–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 * Initialize the samples page
37 */
38export async function initSamplesPage(): Promise<void> {
39 if (initialized) return;
40 initialized = true;
41
42 try {
43 // Load samples data
44 samplesData = await fetchData<SamplesData>("samples.json");
45
46 if (!samplesData || samplesData.cookbooks.length === 0) {
47 showEmptyState();
48 return;
49 }
50
51 // Initialize search with all recipes
52 const allRecipes = samplesData.cookbooks.flatMap((cookbook) =>
53 cookbook.recipes.map(
54 (recipe) =>
55 ({
56 ...recipe,
57 title: recipe.name,
58 cookbookId: cookbook.id,
59 } as SearchableItem & { cookbookId: string })
60 )
61 );
62 search = new FuzzySearch(allRecipes);
63
64 // Setup UI
65 setupModal();
66 setupFilters();
67 setupSearch();
68 setupRecipeListeners();
69 updateResultsCount();
70 } catch (error) {
71 console.error("Failed to initialize samples page:", error);
72 showEmptyState();
73 }
74}
75
76/**
77 * Show empty state when no cookbooks are available

Callers 1

samples.tsFile · 0.85

Calls 6

setupModalFunction · 0.90
showEmptyStateFunction · 0.85
setupFiltersFunction · 0.85
setupSearchFunction · 0.85
setupRecipeListenersFunction · 0.85
updateResultsCountFunction · 0.85

Tested by

no test coverage detected