From 0820b7f3267f56d66045d7762f9742115595f37a Mon Sep 17 00:00:00 2001 From: TrialDragon <31419708+TrialDragon@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:39:54 -0700 Subject: [PATCH] Beautify example showcase site URLs (#12348) # Objective The current example showcase site URLs have white-space and caps in them which looks ugly as an URL. Fixes https://github.com/bevyengine/bevy-website/issues/736 ## Solution To fix this the example showcase tool now makes the category used for the site sections lowercase, separated by a hyphen rather than white-space, and without parentheses. --------- Co-authored-by: Rob Parrett Co-authored-by: vero --- tools/example-showcase/src/main.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/example-showcase/src/main.rs b/tools/example-showcase/src/main.rs index 64279f0bad..3c5853b5eb 100644 --- a/tools/example-showcase/src/main.rs +++ b/tools/example-showcase/src/main.rs @@ -464,7 +464,19 @@ header_message = \"Examples (WebGL2)\" if !to_show.wasm { continue; } - let category_path = root_path.join(&to_show.category); + + // This beautifys the path + // to make it a good looking URL + // rather than having weird whitespace + // and other characters that don't + // work well in a URL path. + let category_path = root_path.join( + &to_show + .category + .replace(['(', ')'], "") + .replace(' ', "-") + .to_lowercase(), + ); if !categories.contains_key(&to_show.category) { let _ = fs::create_dir_all(&category_path); @@ -500,6 +512,10 @@ title = \"{}\" template = \"example{}.html\" weight = {} description = \"{}\" +# This creates redirection pages +# for the old URLs which used +# uppercase letters and whitespace. +aliases = [\"/examples{}/{}/{}\"] [extra] technical_name = \"{}\" @@ -516,6 +532,12 @@ header_message = \"Examples ({})\" }, categories.get(&to_show.category).unwrap(), to_show.description.replace('"', "'"), + match api { + WebApi::Webgpu => "-webgpu", + WebApi::Webgl2 => "", + }, + to_show.category, + &to_show.technical_name.replace('_', "-"), &to_show.technical_name.replace('_', "-"), match api { WebApi::Webgpu => "-webgpu",