Add support for dead links
This commit is contained in:
parent
ef6c07f0ea
commit
08a358b0ce
19
src/main.rs
19
src/main.rs
|
@ -224,7 +224,12 @@ fn main() {
|
|||
None => link_content,
|
||||
}.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);
|
||||
}
|
||||
|
@ -239,11 +244,13 @@ fn main() {
|
|||
None => (link_content.trim().to_lowercase(), link_content)
|
||||
};
|
||||
|
||||
let permalink = page_map.get(&page_id)
|
||||
.unwrap()
|
||||
.permalink.as_str();
|
||||
|
||||
format!("<a href='{}'>{}</a>", permalink, link_text)
|
||||
return match page_map.get(&page_id) {
|
||||
Some(linked_page) => {
|
||||
let permalink = linked_page.permalink.as_str();
|
||||
format!("<a href='{}'>{}</a>", permalink, link_text)
|
||||
},
|
||||
None => format!("<a href='#' class='calathea-404'>{}</a>", link_text),
|
||||
}
|
||||
}).to_string());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue