Add support for dead links

This commit is contained in:
Nat 2023-08-29 15:35:54 -07:00
parent ef6c07f0ea
commit 08a358b0ce
Signed by: nat
GPG Key ID: B53AB05285D710D6
1 changed files with 13 additions and 6 deletions

View File

@ -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());
} }