#![allow(non_snake_case)] use dioxus::prelude::*; use dioxus_router::prelude::*; use std::io::prelude::*; use std::{path::PathBuf, str::FromStr}; fn main() { render_static_pages(); } fn render_static_pages() { for route in Route::SITE_MAP .iter() .flat_map(|seg| seg.flatten().into_iter()) { // check if this is a static segment let mut file_path = PathBuf::from("./"); let mut full_path = String::new(); let mut is_static = true; for segment in &route { match segment { SegmentType::Static(s) => { file_path.push(s); full_path += "/"; full_path += s; } _ => { // skip routes with any dynamic segments is_static = false; break; } } } if is_static { let route = Route::from_str(&full_path).unwrap(); let mut vdom = VirtualDom::new_with_props(RenderPath, RenderPathProps { path: route }); let _ = vdom.rebuild(); file_path.push("index.html"); std::fs::create_dir_all(file_path.parent().unwrap()).unwrap(); let mut file = std::fs::File::create(file_path).unwrap(); let body = dioxus_ssr::render(&vdom); let html = format!( r#"