Rust library to generate static websites
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: current_url on RouteContext

+16 -6
+8 -5
crates/framework/src/lib.rs
··· 197 197 ..Default::default() 198 198 }; 199 199 200 + let params = RouteParams(FxHashMap::default()); 200 201 let mut ctx = RouteContext { 201 - params: page::RouteParams(FxHashMap::default()), 202 + params: &params, 202 203 content: &content_sources, 203 204 assets: &mut page_assets, 205 + current_url: route.url_untyped(&params), 204 206 }; 205 207 206 - let (file_path, mut file) = create_route_file(route, &ctx.params, &dist_dir)?; 208 + let (file_path, mut file) = create_route_file(route, ctx.params, &dist_dir)?; 207 209 let result = route.render(&mut ctx); 208 210 209 211 finish_route( ··· 245 247 }; 246 248 let route_start = SystemTime::now(); 247 249 let mut ctx = RouteContext { 248 - params, 250 + params: &params, 249 251 content: &content_sources, 250 252 assets: &mut pages_assets, 253 + current_url: route.url_untyped(&params), 251 254 }; 252 255 253 - let (file_path, mut file) = create_route_file(route, &ctx.params, &dist_dir)?; 256 + let (file_path, mut file) = create_route_file(route, ctx.params, &dist_dir)?; 254 257 let result = route.render(&mut ctx); 255 258 256 259 build_metadata.pages.push(PageOutput { 257 260 route: route.route_raw(), 258 261 file_path: file_path.to_string_lossy().to_string(), 259 - params: Some(ctx.params.0), 262 + params: Some(params.0), 260 263 }); 261 264 262 265 finish_route(
+3 -1
crates/framework/src/page.rs
··· 16 16 } 17 17 18 18 pub struct RouteContext<'a> { 19 - pub params: RouteParams, 19 + pub params: &'a RouteParams, 20 20 pub content: &'a ContentSources, 21 21 pub assets: &'a mut PageAssets, 22 + pub current_url: String, 22 23 } 23 24 24 25 impl RouteContext<'_> { ··· 90 91 ) -> Result<String, UrlError> 91 92 where 92 93 Self: Sized; 94 + fn url_untyped(&self, params: &RouteParams) -> String; 93 95 } 94 96 95 97 pub trait FullPage: Page + InternalPage + DynamicRoute + Sync {}
+5
crates/macros/src/lib.rs
··· 113 113 #(#list_params;)* 114 114 Ok(format!(#path_for_route)) 115 115 } 116 + 117 + fn url_untyped(&self, params: &maudit::page::RouteParams) -> String { 118 + #(#list_params;)* 119 + format!(#path_for_route) 120 + } 116 121 } 117 122 118 123