From fc0d3fc0e23c799b6d629c4b2d34e94dba9d004b Mon Sep 17 00:00:00 2001
From: jump-and-jump <984292420@qq.com>
Date: Mon, 28 Apr 2025 19:39:53 +0800
Subject: [PATCH] fix: Remove useless calls during initialization (#295)
* fix: Remove useless calls during initialization
* fix: refactor search component and enhance search functionality
* fix: clean up code formatting and improve readability in Search component and global types
---------
Co-authored-by: jump-and-jump <984292420@qq.com>
Co-authored-by: L4Ph <4ranci0ne@gmail.com>
---
src/components/Search.svelte | 100 +++++++++++++++++++++--------------
src/global.d.ts | 33 ++++++++++++
2 files changed, 94 insertions(+), 39 deletions(-)
diff --git a/src/components/Search.svelte b/src/components/Search.svelte
index 584f79ef..9a93a784 100644
--- a/src/components/Search.svelte
+++ b/src/components/Search.svelte
@@ -1,13 +1,18 @@
diff --git a/src/global.d.ts b/src/global.d.ts
index b51df520..8d4042be 100644
--- a/src/global.d.ts
+++ b/src/global.d.ts
@@ -4,5 +4,38 @@ declare global {
interface Window {
// type from '@swup/astro' is incorrect
swup: AstroIntegration;
+ pagefind: {
+ search: (query: string) => Promise<{
+ results: Array<{
+ data: () => Promise;
+ }>;
+ }>;
+ };
}
}
+
+interface SearchResult {
+ url: string;
+ meta: {
+ title: string;
+ };
+ excerpt: string;
+ content?: string;
+ word_count?: number;
+ filters?: Record;
+ anchors?: Array<{
+ element: string;
+ id: string;
+ text: string;
+ location: number;
+ }>;
+ weighted_locations?: Array<{
+ weight: number;
+ balanced_score: number;
+ location: number;
+ }>;
+ locations?: number[];
+ raw_content?: string;
+ raw_url?: string;
+ sub_results?: SearchResult[];
+}