feat: Initial search implementation using pagefind.

This commit is contained in:
2025-04-06 10:40:58 -04:00
parent 6457674de7
commit 573e70a8d2
9 changed files with 104 additions and 21 deletions

View File

@@ -63,16 +63,16 @@ func renderYear<T>(context: PartitionedRenderingContext<T, ArticleMetadata>) ->
baseRenderArticles(context.items, canocicalURL: "/articles/\(context.key)/", title: "Articles in \(context.key)")
}
private struct SearchData: Encodable, Identifiable {
let id: String
private struct SearchData: Encodable {
let url: String
let title: String
let content: String
let body: String
init(article: Item<ArticleMetadata>) throws {
self.id = article.url
self.url = article.url
self.title = article.title
let rawContent: String = try article.absoluteSource.read()
self.content = Self.parse(rawContent)
self.body = Self.parse(rawContent)
}
/// Grabs the metadata (wrapped within `---`), the first title, and the body of the document.