feat(examples): order gallery by board (Arduino Uno first), then title
Sort filteredExamples by the board's position in BOARD_TABS — which puts Arduino Uno first — and alphabetically by title within each board. Applies to the 'All' view and to each board tab. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
9c78fe688e
commit
81fdb0b959
|
|
@ -102,7 +102,15 @@ export const ExamplesGallery: React.FC<ExamplesGalleryProps> = ({ onLoadExample
|
|||
if (searchTokens.length === 0) return true;
|
||||
const hay = exampleHaystack(example);
|
||||
return searchTokens.every((tok) => hay.includes(tok));
|
||||
});
|
||||
})
|
||||
.sort((a, b) => {
|
||||
// Order by board following the BOARD_TABS order (so Arduino Uno comes
|
||||
// first), then alphabetically by title within each board.
|
||||
const ra = BOARD_TABS.findIndex((t) => t.id === getBoardFilter(a));
|
||||
const rb = BOARD_TABS.findIndex((t) => t.id === getBoardFilter(b));
|
||||
if (ra !== rb) return (ra < 0 ? 999 : ra) - (rb < 0 ? 999 : rb);
|
||||
return (a.title ?? '').localeCompare(b.title ?? '');
|
||||
});
|
||||
|
||||
// Count per board for tab badges
|
||||
const boardCounts: Record<string, number> = { all: exampleProjects.length };
|
||||
|
|
|
|||
Loading…
Reference in New Issue