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 <robparrett@gmail.com>
Co-authored-by: vero <email@atlasdostal.com>
This commit is contained in:
TrialDragon 2024-03-17 14:39:54 -07:00 committed by GitHub
parent 36cfb2170f
commit 0820b7f326
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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",