Skip to content

Fix docs search #1078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pgml-dashboard/src/components/accordian/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sailfish::TemplateOnce;
use pgml_components::component;
use sailfish::TemplateOnce;

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

impl Accordian {
Expand Down
3 changes: 1 addition & 2 deletions pgml-dashboard/src/components/accordian/template.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<% use std::iter::zip; %>

<div data-controller="accordian">
<div class="accordian">
<% for i in (0..html_contents.len()) { %>
<% for i in 0..html_contents.len() { %>
<div class="accordian-item">
<div class="accordian-header <% if i == selected { %> selected <% } %>" data-action="click->accordian#titleClick" data-value="accordian-body<%= i %>">
<%- html_titles[i] %>
Expand Down
2 changes: 1 addition & 1 deletion pgml-dashboard/src/components/inputs/range_group/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::components::stimulus::stimulus_target::StimulusTarget;
use pgml_components::component;
use sailfish::TemplateOnce;
use crate::components::stimulus::stimulus_target::StimulusTarget;

#[derive(TemplateOnce, Default)]
#[template(path = "inputs/range_group/template.html")]
Expand Down
6 changes: 1 addition & 5 deletions pgml-dashboard/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#[macro_use]
extern crate rocket;

use rand::{distributions::Alphanumeric, Rng};
use rocket::form::Form;
use rocket::response::Redirect;
use rocket::route::Route;
use rocket::serde::json::Json;
use rocket::{
form::Form,
http::{Cookie, CookieJar},
};
use sailfish::TemplateOnce;
use sqlx::PgPool;
use std::collections::HashMap;
Expand Down
2 changes: 1 addition & 1 deletion pgml-dashboard/src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn blogs_dir() -> String {
}

pub fn docs_dir() -> String {
match var("DASHBOARD_DOCS_DIRECTORY") {
match var("DASHBOARD_CONTENT_DIRECTORY") {
Ok(dir) => dir,
Err(_) => "../pgml-docs/".to_string(),
}
Expand Down
7 changes: 5 additions & 2 deletions pgml-dashboard/src/utils/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,8 @@ impl SearchIndex {
}

pub fn documents() -> Vec<PathBuf> {
let guides = glob::glob(&(config::docs_dir() + "/guides/**/*.md")).expect("glob failed");
let guides =
glob::glob(&(config::docs_dir() + "/docs/guides/**/*.md")).expect("glob failed");
let blogs = glob::glob(&(config::blogs_dir() + "/blog/**/*.md")).expect("glob failed");
guides
.chain(blogs)
Expand Down Expand Up @@ -1406,7 +1407,9 @@ impl SearchIndex {
.split("content")
.last()
.unwrap()
.to_string();
.to_string()
.replace("README", "")
.replace(&config::docs_dir(), "/");
let mut doc = Document::default();
doc.add_text(title_field, &title_text);
doc.add_text(body_field, &body_text);
Expand Down