summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-01-09 22:15:55 +1300
committerBen Bridle <ben@derelict.engineering>2025-01-09 22:16:12 +1300
commitee28abce78ffa3b53ff039ff8640a3b37dc5348b (patch)
tree2cec62a7930874d1164a1d74e24778a9d4b5c286 /src/main.rs
parentec6ef10964fd605d7a911fee47bc3cc0a031bdaa (diff)
downloadtoaster-ee28abce78ffa3b53ff039ff8640a3b37dc5348b.zip
Rewrite link handling and add navigation features to generated HTML
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 2950ee9..a41f801 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,6 +8,8 @@ pub use generate_html::*;
use markdown::*;
use vagabond::*;
+use std::collections::HashSet;
+
const NORMAL: &str = "\x1b[0m";
const BOLD: &str = "\x1b[1m";
@@ -55,6 +57,25 @@ fn main() {
let website = Website::from_path(&source_directory);
+ // Check for duplicate output paths for pages.
+ let mut destinations: HashSet<&str> = HashSet::new();
+ let mut duplicates: HashSet<&str> = HashSet::new();
+ for page in &website.pages {
+ if !destinations.insert(&page.full_url) {
+ duplicates.insert(&page.full_url);
+ };
+ }
+ if !duplicates.is_empty() {
+ for destination in duplicates {
+ warn!("Multiple pages have the output path {destination:?}");
+ for page in &website.pages {
+ if page.full_url == destination {
+ eprintln!(":: {:?}", page.source_path);
+ }
+ }
+ }
+ }
+
let mut destination = destination_directory.clone();
destination.push(make_url_safe(&website.name));
@@ -64,6 +85,7 @@ fn main() {
error!("Failed to delete existing destination directory {destination:?}"));
}
+
for page in &website.pages {
let mut destination = destination.clone();
destination.push(&page.full_url);