Rust library to generate static websites
5
fork

Configure Feed

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

chore: fix macros formatting

+61 -29
+28
.editorconfig
··· 1 + # EditorConfig helps developers define and maintain consistent 2 + # coding styles between different editors and IDEs 3 + # editorconfig.org 4 + 5 + root = true 6 + 7 + [*] 8 + end_of_line = lf 9 + charset = utf-8 10 + trim_trailing_whitespace = true 11 + insert_final_newline = true 12 + indent_style = space 13 + indent_size = 4 14 + 15 + [{*.js,*.ts,*.json}] 16 + indent_size = 2 17 + indent_style = tab 18 + insert_final_newline = true 19 + trim_trailing_whitespace = true 20 + 21 + [*.md] 22 + indent_size = unset 23 + indent_style = space 24 + trim_trailing_whitespace = false 25 + 26 + [{*.yml,*.yaml}] 27 + indent_style = space 28 + indent_size = 2
+1
crates/framework/src/page.rs
··· 45 45 fn route_raw(&self) -> String; 46 46 fn route(&self, params: &RouteParams) -> String; 47 47 fn file_path(&self, params: &RouteParams) -> PathBuf; 48 + fn url(&self, params: &RouteParams) -> String; 48 49 } 49 50 50 51 pub trait FullPage: Page + InternalPage + DynamicPage + Sync {}
+32 -29
crates/macros/src/lib.rs
··· 69 69 let file_path_for_route = url_to_file_path(&path, attrs.is_endpoint_file, &params); 70 70 71 71 let expanded = quote! { 72 - struct RawParams { 73 - #(#struct_def_params,)* 74 - } 72 + struct RawParams { 73 + #(#struct_def_params,)* 74 + } 75 75 76 76 impl RawParams { 77 77 fn get_field_names() -> Vec<&'static str> { 78 - vec![#(stringify!(#struct_def_params)),*] 79 - } 78 + vec![#(stringify!(#struct_def_params)),*] 79 + } 80 80 } 81 81 82 82 impl maudit::page::InternalPage for #struct_name { 83 - fn route_raw(&self) -> String { 84 - #path.to_string() 85 - } 83 + fn route_raw(&self) -> String { 84 + #path.to_string() 85 + } 86 86 87 - fn route(&self, params: &maudit::page::RouteParams) -> String { 88 - #(#list_params;)* 89 - return format!(#path_for_route); 90 - } 87 + fn route(&self, params: &maudit::page::RouteParams) -> String { 88 + #(#list_params;)* 89 + return format!(#path_for_route); 90 + } 91 91 92 - fn file_path(&self, params: &maudit::page::RouteParams) -> std::path::PathBuf { 93 - // List params in the shape of let id = ctx.params.get("id").unwrap().to_string(); 94 - #(#list_params;)* 95 - std::path::PathBuf::from(format!(#file_path_for_route)) 96 - } 92 + fn file_path(&self, params: &maudit::page::RouteParams) -> std::path::PathBuf { 93 + #(#list_params;)* 94 + std::path::PathBuf::from(format!(#file_path_for_route)) 95 + } 96 + 97 + fn url(&self, params: &maudit::page::RouteParams) -> String { 98 + #(#list_params;)* 99 + format!(#path_for_route) 100 + } 97 101 } 98 102 99 103 100 - #dynamic_page_impl 104 + #dynamic_page_impl 101 105 102 106 impl maudit::page::FullPage for #struct_name {} 103 107 ··· 209 213 impl From<RouteParams> for #struct_name { 210 214 fn from(params: RouteParams) -> Self { 211 215 #struct_name { 212 - #(#fields: maudit::params::FromParam::from_param(params.0.get(stringify!(#fields)).unwrap()).unwrap(),)* 213 - 216 + #(#fields: maudit::params::FromParam::from_param(params.0.get(stringify!(#fields)).unwrap()).unwrap(),)* 214 217 } 215 218 } 216 219 } 217 220 218 - impl Into<RouteParams> for #struct_name { 219 - fn into(self) -> RouteParams { 220 - let mut map = maudit::FxHashMap::default(); 221 - #( 222 - map.insert(stringify!(#fields).to_string(), self.#fields.to_string()); 223 - )* 224 - RouteParams(map) 225 - } 226 - } 221 + impl Into<RouteParams> for #struct_name { 222 + fn into(self) -> RouteParams { 223 + let mut map = maudit::FxHashMap::default(); 224 + #( 225 + map.insert(stringify!(#fields).to_string(), self.#fields.to_string()); 226 + )* 227 + RouteParams(map) 228 + } 229 + } 227 230 }; 228 231 229 232 TokenStream::from(expanded)