Skip to content

Commit b4ea9e8

Browse files
committed
make html redirects
1 parent b49ba93 commit b4ea9e8

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

gen-webring-routes.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,31 @@ const fs = require("fs");
33
// Import ze froges
44
const frogs = require("./static/webring/froglist.json");
55

6+
function makeHtmlRedirect(frog) {
7+
return `
8+
<!DOCTYPE HTML>
9+
<html lang="en-US">
10+
<head>
11+
<meta charset="UTF-8">
12+
<meta http-equiv="refresh" content="0; url=${frog.url}">
13+
<script type="text/javascript">
14+
// JS redirect as fallback if the meta tag doesn't work
15+
window.location.href = "${frog.url}"
16+
</script>
17+
<title>Page Redirection</title>
18+
</head>
19+
<body>
20+
<!-- And a link, just in case -->
21+
If you are not redirected automatically, follow this <a href='${frog.url}'>link</a>.
22+
</body>
23+
</html>`;
24+
}
25+
626
function makeRoutes(frog, nextFrog, prevFrog) {
727
fs.mkdirSync(`./static/webring/frogs/${frog.name}`, { recursive: true });
8-
fs.appendFileSync(`./static/webring/frogs/${frog.name}.html`, frog.url);
9-
fs.appendFileSync(`./static/webring/frogs/${frog.name}/next.html`, nextFrog.url);
10-
fs.appendFileSync(`./static/webring/frogs/${frog.name}/prev.html`, prevFrog.url);
28+
fs.appendFileSync(`./static/webring/frogs/${frog.name}.html`, makeHtmlRedirect(frog));
29+
fs.appendFileSync(`./static/webring/frogs/${frog.name}/next.html`, makeHtmlRedirect(nextFrog));
30+
fs.appendFileSync(`./static/webring/frogs/${frog.name}/prev.html`, makeHtmlRedirect(prevFrog));
1131
}
1232

1333
frogs.forEach((frog, i) => {

0 commit comments

Comments
 (0)