Skip to content

Commit

Permalink
Stop website examples from linking to old URL with multiple redirects (
Browse files Browse the repository at this point in the history
…bevyengine#14500)

# Objective

Fixes bevyengine/bevy-website#1558
Followup to bevyengine#12348 

For the website pages extra link, it needs kebab case for the category
name and a trailing forward slash to make the link for the Bevy website
correct and not have unnecessary redirections.

## Solution

Changes the category name to kebab case for the extra link, and adds a
trailing forward slash to the link.

## Testing

I have tested these changes.

Clone my fork with the changes in `bevy-website/generate-wasm-examples/`
then `cd bevy && git switch bevy-website/1558_fix_beautify_example_links
&& cd ..` and then `./generate_wasm_examples.sh` to generate examples.

Afterwards runs `zola serve` and go to `http://127.0.0.1:1111/examples`
and hover over or inspect the cards links / anchors to see that the link
is now correct, click on any of the cards to see that there is no
redirects.
  • Loading branch information
TrialDragon authored Jul 29, 2024
1 parent 396153a commit 7ffd6ea
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tools/example-showcase/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,18 +502,18 @@ header_message = \"Examples (WebGL2)\"
continue;
}

// This beautifys the path
// This beautifys the category name
// 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(),
);
let beautified_category = to_show
.category
.replace(['(', ')'], "")
.replace(' ', "-")
.to_lowercase();

let category_path = root_path.join(&beautified_category);

if !categories.contains_key(&to_show.category) {
let _ = fs::create_dir_all(&category_path);
Expand Down Expand Up @@ -556,7 +556,7 @@ aliases = [\"/examples{}/{}/{}\"]
[extra]
technical_name = \"{}\"
link = \"/examples{}/{}/{}\"
link = \"/examples{}/{}/{}/\"
image = \"../static/screenshots/{}/{}.png\"
code_path = \"content/examples{}/{}\"
shader_code_paths = {:?}
Expand All @@ -581,7 +581,7 @@ header_message = \"Examples ({})\"
WebApi::Webgpu => "-webgpu",
WebApi::Webgl2 => "",
},
&to_show.category,
&beautified_category,
&to_show.technical_name.replace('_', "-"),
&to_show.category,
&to_show.technical_name,
Expand Down

0 comments on commit 7ffd6ea

Please sign in to comment.