Skip to content

Commit

Permalink
feat(docsearch): display 5 hits per category maximum
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Jun 5, 2020
1 parent 9eaf18a commit e589657
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/groupBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export function groupBy<TValue extends object>(
acc[key] = [];
}

acc[key].push(item);
// We limit each section to show 5 hits maximum.
// This acts as a frontend alternative to `distinct`.
if (acc[key].length < 5) {
acc[key].push(item);
}

return acc;
}, {});
Expand Down

0 comments on commit e589657

Please sign in to comment.