Skip to content

Commit

Permalink
Add subpath redirects (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
huynhtrankhanh authored Oct 12, 2023
1 parent 9bdf77e commit 92e96df
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v2
18 changes: 18 additions & 0 deletions pages/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<#include "incl/macros.html">
<script>
const path = window.location.pathname;
const stdlibRegex = /^\/(stdlib|library)\//;
const refmanRegex = /^\/distrib\/(.*)\/refman\//;
const stdlibDistribRegex = /^\/distrib\/(.*)\/stdlib\//;
if (stdlibRegex.test(path)) {
window.location = path.replace(stdlibRegex, "/doc/<#CURRENTVERSIONTAG>/stdlib/");
} else if (refmanRegex.test(path)) {
const version = path.match(refmanRegex)[1];
window.location = path.replace(refmanRegex, "/doc/" + version + "/refman/");
} else if (stdlibDistribRegex.test(path)) {
const version = path.match(stdlibDistribRegex)[1];
window.location = path.replace(stdlibDistribRegex, "/doc/" + version + "/stdlib/");
} else {
document.write("<h1>Not found</h1>");
}
</script>
4 changes: 2 additions & 2 deletions pages/distrib/current/refman/changes.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#include "incl/macros.html">
<head>
<meta http-equiv="Refresh" content="0; URL=https://coq.github.io/doc/<#CURRENTVERSIONTAG>/refman/changes.html" />
</head>
<meta http-equiv="Refresh" content="0; URL=/doc/<#CURRENTVERSIONTAG>/refman/changes.html" />
</head>
2 changes: 1 addition & 1 deletion pages/distrib/current/refman/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#include "incl/macros.html">
<head>
<meta http-equiv="Refresh" content="0; URL=https://coq.github.io/doc/<#CURRENTVERSIONTAG>/refman/" />
<meta http-equiv="Refresh" content="0; URL=/doc/<#CURRENTVERSIONTAG>/refman/" />
</head>
2 changes: 1 addition & 1 deletion pages/distrib/current/stdlib/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#include "incl/macros.html">
<head>
<meta http-equiv="Refresh" content="0; URL=https://coq.github.io/doc/<#CURRENTVERSIONTAG>/stdlib/" />
<meta http-equiv="Refresh" content="0; URL=/doc/<#CURRENTVERSIONTAG>/stdlib/" />
</head>
2 changes: 1 addition & 1 deletion pages/library/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#include "incl/macros.html">
<head>
<meta http-equiv="Refresh" content="0; URL=https://coq.github.io/doc/<#CURRENTVERSIONTAG>/stdlib/" />
<meta http-equiv="Refresh" content="0; URL=/doc/<#CURRENTVERSIONTAG>/stdlib/" />
</head>
2 changes: 1 addition & 1 deletion pages/stdlib/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#include "incl/macros.html">
<head>
<meta http-equiv="Refresh" content="0; URL=https://coq.github.io/doc/<#CURRENTVERSIONTAG>/stdlib/" />
<meta http-equiv="Refresh" content="0; URL=/doc/<#CURRENTVERSIONTAG>/stdlib/" />
</head>

0 comments on commit 92e96df

Please sign in to comment.