Skip to content

Commit e790980

Browse files
authored
Fix docs search (#1078)
1 parent 481d623 commit e790980

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

pgml-dashboard/src/components/accordian/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use sailfish::TemplateOnce;
21
use pgml_components::component;
2+
use sailfish::TemplateOnce;
33

44
// This component will probably not work very well if two are on the same page at once. We can get
55
// around it if we include some randomness with the data values in the template.html but that
@@ -10,7 +10,7 @@ use pgml_components::component;
1010
pub struct Accordian {
1111
html_contents: Vec<String>,
1212
html_titles: Vec<String>,
13-
selected: usize
13+
selected: usize,
1414
}
1515

1616
impl Accordian {

pgml-dashboard/src/components/accordian/template.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<% use std::iter::zip; %>
21

32
<div data-controller="accordian">
43
<div class="accordian">
5-
<% for i in (0..html_contents.len()) { %>
4+
<% for i in 0..html_contents.len() { %>
65
<div class="accordian-item">
76
<div class="accordian-header <% if i == selected { %> selected <% } %>" data-action="click->accordian#titleClick" data-value="accordian-body<%= i %>">
87
<%- html_titles[i] %>

pgml-dashboard/src/components/inputs/range_group/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use crate::components::stimulus::stimulus_target::StimulusTarget;
12
use pgml_components::component;
23
use sailfish::TemplateOnce;
3-
use crate::components::stimulus::stimulus_target::StimulusTarget;
44

55
#[derive(TemplateOnce, Default)]
66
#[template(path = "inputs/range_group/template.html")]

pgml-dashboard/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#[macro_use]
22
extern crate rocket;
33

4-
use rand::{distributions::Alphanumeric, Rng};
4+
use rocket::form::Form;
55
use rocket::response::Redirect;
66
use rocket::route::Route;
77
use rocket::serde::json::Json;
8-
use rocket::{
9-
form::Form,
10-
http::{Cookie, CookieJar},
11-
};
128
use sailfish::TemplateOnce;
139
use sqlx::PgPool;
1410
use std::collections::HashMap;

pgml-dashboard/src/utils/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn blogs_dir() -> String {
4242
}
4343

4444
pub fn docs_dir() -> String {
45-
match var("DASHBOARD_DOCS_DIRECTORY") {
45+
match var("DASHBOARD_CONTENT_DIRECTORY") {
4646
Ok(dir) => dir,
4747
Err(_) => "../pgml-docs/".to_string(),
4848
}

pgml-dashboard/src/utils/markdown.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,8 @@ impl SearchIndex {
13401340
}
13411341

13421342
pub fn documents() -> Vec<PathBuf> {
1343-
let guides = glob::glob(&(config::docs_dir() + "/guides/**/*.md")).expect("glob failed");
1343+
let guides =
1344+
glob::glob(&(config::docs_dir() + "/docs/guides/**/*.md")).expect("glob failed");
13441345
let blogs = glob::glob(&(config::blogs_dir() + "/blog/**/*.md")).expect("glob failed");
13451346
guides
13461347
.chain(blogs)
@@ -1406,7 +1407,9 @@ impl SearchIndex {
14061407
.split("content")
14071408
.last()
14081409
.unwrap()
1409-
.to_string();
1410+
.to_string()
1411+
.replace("README", "")
1412+
.replace(&config::docs_dir(), "/");
14101413
let mut doc = Document::default();
14111414
doc.add_text(title_field, &title_text);
14121415
doc.add_text(body_field, &body_text);

0 commit comments

Comments
 (0)