···65656666 // First argument: either a path expression or a named argument like locales(...)
6767 if input.peek(Ident) && input.peek2(syn::token::Paren) {
6868- // First argument is a named argument (e.g., locales(...))
6969- // This means it's a variant-only route with no base path
6868+ // If the first argument is a named one, that means there's no base path and this route should only have variants
7069 let ident: Ident = input.parse()?;
7170 let ident_str = ident.to_string();
7271···8281 ));
8382 }
8483 } else {
8585- // First argument is a path expression
8484+ // First argument is a path expression, e.g., "/about" so proceed as normal
8685 path = Some(input.parse::<Expr>()?);
8786 }
88878989- // Parse remaining named arguments (locales, middleware, etc.)
8888+ // Parse remaining named arguments (right now just locales(...))
9089 while !input.is_empty() {
9190 input.parse::<Token![,]>()?;
9291···9493 break;
9594 }
96959797- // All subsequent arguments must be named (e.g., locales(...), middleware(...))
9696+ // All subsequent arguments must be named (e.g., locales(...), the path must be first)
9897 if input.peek(Ident) && input.peek2(syn::token::Paren) {
9998 let ident: Ident = input.parse()?;
10099 let ident_str = ident.to_string();
···160159 let struct_name = &item_struct.ident;
161160162161 // Generate variants method based on locales
163163- let variant_methods = if !args.locales.is_empty() {
162162+ let variant_method = if !args.locales.is_empty() {
164163 let variant_tuples = args.locales.iter().map(|variant| {
165164 let locale_name = variant.locale.to_string();
166165···218217 impl maudit::route::InternalRoute for #struct_name {
219218 #route_raw_impl
220219221221- #variant_methods
220220+ #variant_method
222221 }
223222224223 impl maudit::route::FullRoute for #struct_name {
+10-25
crates/maudit/src/build.rs
···1515 content::ContentSources,
1616 is_dev,
1717 logging::print_title,
1818- route::{
1919- CachedRoute, DynamicRouteContext, FullRoute, InternalRoute, PageContext, PageParams,
2020- build_file_path_with_params, build_url_with_params,
2121- },
2222- routing::{extract_params_from_raw_route, guess_if_route_is_endpoint},
1818+ route::{CachedRoute, DynamicRouteContext, FullRoute, InternalRoute, PageContext, PageParams},
1919+ routing::extract_params_from_raw_route,
2320};
2421use colored::{ColoredString, Colorize};
2522use log::{debug, info, trace, warn};
···239236 let mut route_assets =
240237 RouteAssets::new(&route_assets_options, Some(image_cache.clone()));
241238242242- let url = if variant_path.starts_with('/') {
243243- variant_path.clone()
244244- } else {
245245- format!("/{}", variant_path)
246246- };
239239+ let params = PageParams::default();
240240+ let url = cached_route.variant_url(¶ms, &variant_id)?;
247241248242 let result = route.build(&mut PageContext::from_static_route(
249243 content_sources,
···253247 Some(variant_id.clone()),
254248 ))?;
255249256256- let file_path = options
257257- .output_dir
258258- .join(variant_path.trim_start_matches('/'))
259259- .join("index.html");
250250+ let file_path =
251251+ cached_route.variant_file_path(¶ms, &options.output_dir, &variant_id)?;
260252261253 write_route_file(&result, &file_path)?;
262254···295287 warn!(target: "build", "Variant {} has dynamic parameters but Route::pages returned an empty Vec.", variant_id.bold());
296288 } else {
297289 for page in pages {
298298- let url = build_url_with_params(
299299- &variant_path,
300300- &variant_params,
301301- &page.0,
302302- guess_if_route_is_endpoint(&variant_path),
303303- );
290290+ let url = cached_route.variant_url(&page.0, &variant_id)?;
304291305292 let content = route.build(&mut PageContext::from_dynamic_route(
306293 &page,
···311298 Some(variant_id.clone()),
312299 ))?;
313300314314- let file_path = build_file_path_with_params(
315315- &variant_path,
316316- &variant_params,
301301+ let file_path = cached_route.variant_file_path(
317302 &page.0,
318303 &options.output_dir,
319319- guess_if_route_is_endpoint(&variant_path),
320320- );
304304+ &variant_id,
305305+ )?;
321306322307 write_route_file(&content, &file_path)?;
323308