diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2025-01-18 09:57:42 +1300 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2025-01-18 09:57:42 +1300 |
commit | b40c687689763b5c7d6d33fe3c6149c38c6248bb (patch) | |
tree | 77687679d9a212c6e16ec3be003c6dc09f7de944 /src | |
parent | 123a223f7e3e9271fda3d7ff687c4a7d3fc257a8 (diff) | |
download | toaster-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.rs | 6 |
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; |