From e5896579be18e65b2f44918f125800e40d4c66bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Fri, 5 Jun 2020 14:44:55 +0200 Subject: [PATCH] feat(docsearch): display 5 hits per category maximum --- src/utils/groupBy.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/groupBy.ts b/src/utils/groupBy.ts index 5ea2731e..f8837400 100644 --- a/src/utils/groupBy.ts +++ b/src/utils/groupBy.ts @@ -9,7 +9,11 @@ export function groupBy( 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; }, {});