Skip to content

Commit be03897

Browse files
committed
New site search
1 parent 4bd0bfc commit be03897

File tree

13 files changed

+3958
-2339
lines changed

13 files changed

+3958
-2339
lines changed

pgml-dashboard/src/api/cms.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,15 @@ impl Collection {
559559
}
560560

561561
#[get("/search?<query>", rank = 20)]
562-
async fn search(query: &str, index: &State<crate::utils::markdown::SearchIndex>) -> ResponseOk {
563-
let results = index.search(query).unwrap();
562+
async fn search(
563+
query: &str,
564+
site_search: &State<crate::utils::markdown::SiteSearch>,
565+
) -> ResponseOk {
566+
eprintln!("\n\nWE IN HERE\n\n");
567+
let results = site_search
568+
.search(query)
569+
.await
570+
.expect("Error performing search");
564571

565572
ResponseOk(
566573
Template(Search {
@@ -779,7 +786,7 @@ This is the end of the markdown
779786
async fn rocket() -> Rocket<Build> {
780787
dotenv::dotenv().ok();
781788
rocket::build()
782-
.manage(crate::utils::markdown::SearchIndex::open().unwrap())
789+
// .manage(crate::utils::markdown::SearchIndex::open().unwrap())
783790
.mount("/", crate::api::cms::routes())
784791
}
785792

pgml-dashboard/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,18 @@ async fn main() {
9292
// it's important to hang on to sentry so it isn't dropped and stops reporting
9393
let _sentry = configure_reporting().await;
9494

95-
markdown::SearchIndex::build().await.unwrap();
95+
// markdown::SearchIndex::build().await.unwrap();
96+
97+
let site_search = markdown::SiteSearch::new()
98+
.await
99+
.expect("Error initializing site search");
96100

97101
pgml_dashboard::migrate(guards::Cluster::default(None).pool())
98102
.await
99103
.unwrap();
100104

101105
let _ = rocket::build()
102-
.manage(markdown::SearchIndex::open().unwrap())
106+
.manage(site_search)
103107
.mount("/", rocket::routes![index, error])
104108
.mount("/dashboard/static", FileServer::from(config::static_dir()))
105109
.mount("/dashboard", pgml_dashboard::routes())

0 commit comments

Comments
 (0)