From a9c45ef6de84df758194e3a9428faee8c69065ae Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Wed, 15 Jan 2025 09:23:00 +1300 Subject: Implement redirects Source files with extension .redirect will be converted into redirect pages linking to the internal-style URL in each file. --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main.rs') 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); + } + } } -- cgit v1.2.3-70-g09d2