summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2025-01-18 09:57:42 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2025-01-18 09:57:42 +1300
commitb40c687689763b5c7d6d33fe3c6149c38c6248bb (patch)
tree77687679d9a212c6e16ec3be003c6dc09f7de944 /src
parent123a223f7e3e9271fda3d7ff687c4a7d3fc257a8 (diff)
downloadtoaster-b40c687689763b5c7d6d33fe3c6149c38c6248bb.zip
Fix internal links to headings on another page
The heading section of the link wasn't being suffixed to the generated link target, so links to a heading on another page were just regular links to the top of that page.
Diffstat (limited to 'src')
-rw-r--r--src/collect_files.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/collect_files.rs b/src/collect_files.rs
index cf39ebe..dfcc847 100644
--- a/src/collect_files.rs
+++ b/src/collect_files.rs
@@ -296,13 +296,15 @@ impl Website {
let path = make_url_safe(&segments.join("/"));
for page in &self.pages {
if page.full_url == path {
+ let root = from.root();
if let Some(heading) = heading {
if !page.headings.iter().any(|h| h.url == make_url_safe(heading)) {
warn!("Page {:?} contains link to nonexistent heading {heading:?} on page {path:?}", from.name());
}
+ return Some(format!("{root}{path}.{ext}#{heading}"));
+ } else {
+ return Some(format!("{root}{path}.{ext}"));
}
- let root = from.root();
- return Some(format!("{root}{path}.{ext}"));
}
}
return None;