diff --git a/src/lib/utils/search.ts b/src/lib/utils/search.ts
index f7bbea4..45540a8 100644
--- a/src/lib/utils/search.ts
+++ b/src/lib/utils/search.ts
@@ -30,12 +30,16 @@ export function createPostsIndex(data: BlogPost[]) {
}
export function searchPostsIndex(searchTerm: string) {
+ if (!searchTerm) {
+ return [];
+ }
+
const match = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const results = postsIndex.search(match);
return results
.map((index) => posts[index as number])
- .map(({ slug, title, excerpt, tags }) => {
+ .map(({ slug, title = '', excerpt = '', tags = [] }) => {
return {
slug,
title: replaceTextWithMarker(title, match),
@@ -46,11 +50,23 @@ export function searchPostsIndex(searchTerm: string) {
}
function replaceTextWithMarker(text: string, match: string) {
+ if (!text) {
+ return '';
+ }
+
+ if (!match) {
+ return text;
+ }
+
const regex = new RegExp(match, 'gi');
- return text.replaceAll(regex, (match) => `${match}`);
+ return text.replaceAll(regex, (matchedText) => `${matchedText}`);
}
function getMatches(text: string, searchTerm: string, limit = 1) {
+ if (!searchTerm) {
+ return [];
+ }
+
const regex = new RegExp(searchTerm, 'gi');
const indexes = [];
let matches = 0;
diff --git a/src/routes/(pages)/about/+page.svelte b/src/routes/(pages)/about/+page.svelte
index 0c5c23b..46cc68b 100644
--- a/src/routes/(pages)/about/+page.svelte
+++ b/src/routes/(pages)/about/+page.svelte
@@ -23,7 +23,6 @@
{ name: 'Performance & Efficiency', id: 'performanceEfficiency' },
{ name: 'Security & Reliability', id: 'securityReliability' },
{ name: 'User Experience & Accessibility', id: 'userExperience' },
- { name: 'Future use cases', id: 'futureUses' },
{ name: 'Integration & Interoperability', id: 'integration' }
]
},