diff --git a/pgml-dashboard/src/api/docs.rs b/pgml-dashboard/src/api/docs.rs index 34cfbc0f4..89b1f286b 100644 --- a/pgml-dashboard/src/api/docs.rs +++ b/pgml-dashboard/src/api/docs.rs @@ -52,7 +52,6 @@ async fn doc_handler(path: PathBuf, cluster: &Cluster) -> Result( folder: &'a Path, content: &'a str, ) -> Result { - let url = path.clone(); + let mut path = path + .to_str() + .expect("path must convert to a string") + .to_string(); + let mut url = path.clone(); + if path.ends_with("/") { + path.push_str("README"); + url.push_str("./"); + } // Get the document content let path = Path::new(&content) .join(folder) - .join(&(path.to_str().unwrap().to_string() + ".md")); + .join(&(path.to_string() + ".md")); - info!("path: {:?}", path); // Read to string let contents = match tokio::fs::read_to_string(&path).await { Ok(contents) => contents, @@ -207,7 +213,7 @@ async fn render<'a>( // Handle navigation for nav_link in nav_links.iter_mut() { - nav_link.should_open(&url.to_str().unwrap().to_string()); + nav_link.should_open(&url); } let user = if cluster.context.user.is_anonymous() { diff --git a/pgml-dashboard/src/utils/markdown.rs b/pgml-dashboard/src/utils/markdown.rs index 7547d6d87..c4c6222a3 100644 --- a/pgml-dashboard/src/utils/markdown.rs +++ b/pgml-dashboard/src/utils/markdown.rs @@ -572,8 +572,12 @@ pub fn get_sub_links(list: &markdown::mdast::List) -> Result> { for node in link.children.iter() { match node { markdown::mdast::Node::Text(text) => { - let url = + let mut url = Path::new(&link.url).with_extension(""); + if url.ends_with("README") { + url = + url.parent().unwrap().join("./").into(); + } let url = Path::new("/docs/guides") .join(url) .into_os_string() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy