Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd0c2643

Browse files
authored
hide README extension in urls (#1065)
1 parent8788c2b commitd0c2643

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

‎pgml-dashboard/src/api/docs.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ async fn doc_handler(path: PathBuf, cluster: &Cluster) -> Result<ResponseOk, Sta
5252
.expect("could not parse table of contents markdown");
5353
let guides = markdown::parse_summary_into_nav_links(&mdast)
5454
.expect("could not extract nav links from table of contents");
55-
5655
render(
5756
cluster,
5857
&path,
@@ -137,14 +136,21 @@ async fn render<'a>(
137136
folder:&'aPath,
138137
content:&'astr,
139138
) ->Result<ResponseOk,Status>{
140-
let url = path.clone();
139+
letmut path = path
140+
.to_str()
141+
.expect("path must convert to a string")
142+
.to_string();
143+
letmut url = path.clone();
144+
if path.ends_with("/"){
145+
path.push_str("README");
146+
url.push_str("./");
147+
}
141148

142149
// Get the document content
143150
let path =Path::new(&content)
144151
.join(folder)
145-
.join(&(path.to_str().unwrap().to_string() +".md"));
152+
.join(&(path.to_string() +".md"));
146153

147-
info!("path: {:?}", path);
148154
// Read to string
149155
let contents =match tokio::fs::read_to_string(&path).await{
150156
Ok(contents) => contents,
@@ -207,7 +213,7 @@ async fn render<'a>(
207213

208214
// Handle navigation
209215
for nav_linkin nav_links.iter_mut(){
210-
nav_link.should_open(&url.to_str().unwrap().to_string());
216+
nav_link.should_open(&url);
211217
}
212218

213219
let user =if cluster.context.user.is_anonymous(){

‎pgml-dashboard/src/utils/markdown.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,12 @@ pub fn get_sub_links(list: &markdown::mdast::List) -> Result<Vec<NavLink>> {
572572
for nodein link.children.iter(){
573573
match node{
574574
markdown::mdast::Node::Text(text) =>{
575-
let url =
575+
letmuturl =
576576
Path::new(&link.url).with_extension("");
577+
if url.ends_with("README"){
578+
url =
579+
url.parent().unwrap().join("./").into();
580+
}
577581
let url =Path::new("/docs/guides")
578582
.join(url)
579583
.into_os_string()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp