diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-01-15 09:23:00 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-01-15 09:23:05 +1300 |
commit | a9c45ef6de84df758194e3a9428faee8c69065ae (patch) | |
tree | e9080dac289cba8fba02a9643801b50375e902fa /src/main.rs | |
parent | e96bbf19171452de9d269a98dc0f4171d1bf46b1 (diff) | |
download | toaster-a9c45ef6de84df758194e3a9428faee8c69065ae.zip |
Implement redirects
Source files with extension .redirect will be converted into redirect
pages linking to the internal-style URL in each file.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index a41f801..a742cfe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -121,6 +121,18 @@ fn main() { error!("Failed to copy static directory {:?} to {:?}", static_dir.source_path, destination)); } + + for redirect in &website.redirects { + let mut destination = destination.clone(); + destination.push(&redirect.full_url); + if let Some(path) = website.has_page(redirect, &redirect.redirect, "html") { + if args.html { + write_file(&generate_html_redirect(&path), &destination, "html"); + } + } else { + warn!("Redirect {:?} links to nonexistent page {:?}", redirect.name, redirect.redirect); + } + } } |