Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #111: fix search error for no results
b6822db fix search error for no results (Graeme Byrne) Pull request description: Fix for [The search box in blog section does not work #108](#108). Search worked when there was a result but when the user entered something in search bar which had no result then searched again nothing would appear when the user searched for something which should return a result. To prevent this issue, the functions in `lib/utils/search.ts` ensure that if there is no search term or no matching results, they return default values (like empty arrays or the original text) and properly handle new searches, ensuring the UI remains responsive and updates with results as expected. ``` export function searchPostsIndex(searchTerm: string) { if (!searchTerm) { return []; } ``` ``` function replaceTextWithMarker(text: string, match: string) { if (!text) { return ''; } if (!match) { return text; } ``` ``` function getMatches(text: string, searchTerm: string, limit = 1) { if (!searchTerm) { return []; } ``` ACKs for top commit: josecelano: ACK b6822db Tree-SHA512: aaa332b8b32219cca16bf5dbfa64e6ff60f61b8305d86dc424e40478837db2fc0496e1003ecfe0f697fb433db71082154f387492ff2034237c411df6ae678ba0
- Loading branch information