Skip to content

Commit

Permalink
Beautify example showcase site URLs (#12348)
Browse files Browse the repository at this point in the history
# Objective

The current example showcase site URLs have white-space and caps in them
which looks ugly as an URL.

Fixes bevyengine/bevy-website#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 <[email protected]>
Co-authored-by: vero <[email protected]>
  • Loading branch information
3 people authored Mar 17, 2024
1 parent 36cfb21 commit 0820b7f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tools/example-showcase/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 = \"{}\"
Expand All @@ -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",
Expand Down

0 comments on commit 0820b7f

Please sign in to comment.