fix link detection

master
Tomáš Mládek 2021-07-25 17:31:18 +02:00
parent 526b5a5507
commit 850e65b5df
1 changed files with 10 additions and 3 deletions

View File

@ -237,17 +237,24 @@ async fn render(
let mut nodes: 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)| {
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
.iter()
.map(|l| normalize_name(l))
.filter(|link| page_ids.contains(link))
.for_each(|link| {
links.push(
[
("source".to_string(), path.clone()),
("source".to_string(), normalized_path.clone()),
("target".to_string(), link.clone()),
]
.iter()