fix link detection
This commit is contained in:
parent
526b5a5507
commit
850e65b5df
1 changed files with 10 additions and 3 deletions
13
src/main.rs
13
src/main.rs
|
@ -237,17 +237,24 @@ async fn render(
|
||||||
let mut nodes: Vec<HashMap<String, String>> = vec![];
|
let mut nodes: Vec<HashMap<String, String>> = vec![];
|
||||||
let mut links: Vec<HashMap<String, String>> = vec![];
|
let mut links: Vec<HashMap<String, String>> = vec![];
|
||||||
|
|
||||||
let page_ids: Vec<&String> = cache.pages.keys().collect();
|
let page_ids: Vec<String> = cache.pages.keys().map(|n| normalize_name(n)).collect();
|
||||||
|
|
||||||
&cache.pages.iter().for_each(|(path, page)| {
|
&cache.pages.iter().for_each(|(path, page)| {
|
||||||
nodes.push([("id".to_string(), path.clone())].iter().cloned().collect());
|
let normalized_path = normalize_name(path);
|
||||||
|
nodes.push(
|
||||||
|
[("id".to_string(), normalized_path.clone())]
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.collect(),
|
||||||
|
);
|
||||||
page.links
|
page.links
|
||||||
.iter()
|
.iter()
|
||||||
|
.map(|l| normalize_name(l))
|
||||||
.filter(|link| page_ids.contains(link))
|
.filter(|link| page_ids.contains(link))
|
||||||
.for_each(|link| {
|
.for_each(|link| {
|
||||||
links.push(
|
links.push(
|
||||||
[
|
[
|
||||||
("source".to_string(), path.clone()),
|
("source".to_string(), normalized_path.clone()),
|
||||||
("target".to_string(), link.clone()),
|
("target".to_string(), link.clone()),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Reference in a new issue