Add support for dead links
This commit is contained in:
parent
ef6c07f0ea
commit
08a358b0ce
17
src/main.rs
17
src/main.rs
|
@ -224,7 +224,12 @@ fn main() {
|
||||||
None => link_content,
|
None => link_content,
|
||||||
}.trim().to_lowercase();
|
}.trim().to_lowercase();
|
||||||
|
|
||||||
let incoming_pages = incoming_map.get_mut(&page_id).unwrap();
|
let incoming_pages = match incoming_map.get_mut(&page_id) {
|
||||||
|
Some(v) => v,
|
||||||
|
|
||||||
|
// The page being referenced doesn't exist (a red link)
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
incoming_pages.push(page);
|
incoming_pages.push(page);
|
||||||
}
|
}
|
||||||
|
@ -239,11 +244,13 @@ fn main() {
|
||||||
None => (link_content.trim().to_lowercase(), link_content)
|
None => (link_content.trim().to_lowercase(), link_content)
|
||||||
};
|
};
|
||||||
|
|
||||||
let permalink = page_map.get(&page_id)
|
return match page_map.get(&page_id) {
|
||||||
.unwrap()
|
Some(linked_page) => {
|
||||||
.permalink.as_str();
|
let permalink = linked_page.permalink.as_str();
|
||||||
|
|
||||||
format!("<a href='{}'>{}</a>", permalink, link_text)
|
format!("<a href='{}'>{}</a>", permalink, link_text)
|
||||||
|
},
|
||||||
|
None => format!("<a href='#' class='calathea-404'>{}</a>", link_text),
|
||||||
|
}
|
||||||
}).to_string());
|
}).to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue