Skip to content

Commit 3f97241

Browse files
committed
docs: add 404 redirect for old docs
1 parent 13928b6 commit 3f97241

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,6 @@ wheelhouse
300300
docs/.cache/
301301
docs/public
302302
node_modules
303+
api/
304+
site/
305+
!404.html

404.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<script>
9+
const websitePath = window.location.pathname;
10+
const versionRegex = /(\w.+)\/(latest|([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?)/;
11+
12+
if (websitePath.search(versionRegex) === -1) {
13+
let projectName = "aws-lambda-powertools-python"
14+
// redirect old links to latest version alias
15+
window.location = websitePath.replace(projectName, `${projectName}/latest`)
16+
}
17+
</script>
18+
</head>
19+
20+
</html>

0 commit comments

Comments
 (0)