Skip to content

Commit 18f21ff

Browse files
committed
Implement static file "redirects"
1 parent 1d3d79e commit 18f21ff

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/redirect.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ pub static STATIC_FILES_REDIRECTS: &[(&str, &str)] = &[
4848
// Pre-2018 whitepaper locations
4949
(
5050
"pdfs/Rust-npm-Whitepaper.pdf",
51-
"/static/pdfs/Rust-npm-Whitepaper.pdf",
51+
"static/pdfs/Rust-npm-Whitepaper.pdf",
5252
),
5353
(
5454
"pdfs/Rust-Tilde-Whitepaper.pdf",
55-
"/static/pdfs/Rust-Tilde-Whitepaper.pdf",
55+
"static/pdfs/Rust-Tilde-Whitepaper.pdf",
5656
),
5757
];
5858

@@ -83,9 +83,11 @@ static PRE_2018_LOCALES: &[&str] = &[
8383

8484
pub fn create_redirects(ctx: &RenderCtx) -> anyhow::Result<()> {
8585
// Static file redirects, no need to support languages
86-
// for (src, dst) in STATIC_FILES_REDIRECTS {
87-
// render_redirect(ctx, src, dst)?;
88-
// }
86+
// We cannot really make non-HTML redirects easily, so we just duplicate the file contents
87+
// under both paths.
88+
for (src, dst) in STATIC_FILES_REDIRECTS {
89+
ctx.copy_asset_file(dst, src)?;
90+
}
8991

9092
// if let Some((_, dest)) = STATIC_FILES_REDIRECTS.iter().find(|(src, _)| src == &path) {
9193
// return Some(Redirect::permanent(*dest));

0 commit comments

Comments
 (0)