Skip to content

Commit 9ebf95b

Browse files
committed
description and tags searched as well as title
1 parent f465bb8 commit 9ebf95b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/hooks/useSnippets.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ export const useSnippets = () => {
2424
if (searchParams.has(QueryParams.SEARCH)) {
2525
return data
2626
.find((item) => item.name === category)
27-
?.snippets.filter((item) =>
28-
item.title
29-
.toLowerCase()
30-
.includes(
31-
(searchParams.get(QueryParams.SEARCH) || "").toLowerCase()
32-
)
33-
);
27+
?.snippets.filter((item) => {
28+
const searchTerm = (
29+
searchParams.get(QueryParams.SEARCH) || ""
30+
).toLowerCase();
31+
return (
32+
item.title.toLowerCase().includes(searchTerm) ||
33+
item.description.toLowerCase().includes(searchTerm) ||
34+
item.tags.some((tag) => tag.toLowerCase().includes(searchTerm))
35+
);
36+
});
3437
}
3538
return data.find((item) => item.name === category)?.snippets;
3639
}, [category, data, searchParams]);

0 commit comments

Comments
 (0)