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>
This commit is contained in:
jump-and-jump
2025-04-28 19:39:53 +08:00
committed by GitHub
parent 0b5d290d30
commit fc0d3fc0e2
2 changed files with 94 additions and 39 deletions
+33
View File
@@ -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<SearchResult>;
}>;
}>;
};
}
}
interface SearchResult {
url: string;
meta: {
title: string;
};
excerpt: string;
content?: string;
word_count?: number;
filters?: Record<string, unknown>;
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[];
}