File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 20
20
node-version : 18
21
21
cache : npm
22
22
23
+ - name : test thing
24
+ run : node gen-webring-routes.js
25
+
23
26
- name : Install dependencies
24
27
run : npm ci
25
28
- name : Build website
Original file line number Diff line number Diff line change
1
+ const fs = require ( "fs" ) ;
2
+
3
+ // Import ze froges
4
+ const frogs = require ( "./static/webring/froglist.json" ) ;
5
+
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
+
26
+ function makeRoutes ( frog , nextFrog , prevFrog ) {
27
+ fs . mkdirSync ( `./static/webring/frogs/${ frog . name } ` , { recursive : true } ) ;
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 ) ) ;
31
+ }
32
+
33
+ frogs . forEach ( ( frog , i ) => {
34
+ const nextFrog = frogs . at ( ( i + 1 ) % frogs . length ) ;
35
+ const prevFrog = frogs . at ( i - 1 ) ; // array.at(-1) returns the last element
36
+
37
+ makeRoutes ( frog , nextFrog , prevFrog ) ;
38
+ } ) ;
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "name" : " gp-blog" ,
4
+ "url" : " https://graphics-programming.org/"
5
+ },
6
+ {
7
+ "name" : " bluescreen" ,
8
+ "url" : " https://fumagalli.ar/"
9
+ }
10
+ ]
You can’t perform that action at this time.
0 commit comments