File tree 2 files changed +39
-3
lines changed
2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 1
1
const fs = require ( "fs" ) ;
2
2
3
- function makeRoute ( ) {
4
- fs . appendFileSync ( './static/test.html' , 'Hello world!' ) ;
3
+ // Import ze froges
4
+ const frogs = require ( "static/webring/froglist.json" ) ;
5
+
6
+ function makeRoutes ( frog , nextFrog , prevFrog ) {
7
+ fs . appendFileSync ( `./static/webring/frogs/${ frog . name } .html` , frog . url ) ;
8
+ fs . appendFileSync ( `./static/webring/frogs/${ frog . name } /next.html` , nextFrog . url ) ;
9
+ fs . appendFileSync ( `./static/webring/frogs/${ frog . name } /prev.html` , prevFrog . url ) ;
5
10
}
6
11
7
- makeRoute ( ) ;
12
+ frogs . forEach ( ( frog , i ) => {
13
+ const nextFrog = frogs . at ( ( i + 1 ) % frogs . length ) ;
14
+ const prevFrog = frogs . at ( i - 1 ) ; // array.at(-1) returns the last element
15
+
16
+ makeRoutes ( frog , nextFrog , prevFrog ) ;
17
+ } ) ;
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
+ {
11
+ "name" : " test1" ,
12
+ "url" : " https://test1.frog/"
13
+ },
14
+ {
15
+ "name" : " test2" ,
16
+ "url" : " https://test2.frog/"
17
+ },
18
+ {
19
+ "name" : " test3" ,
20
+ "url" : " https://test3.frog/"
21
+ },
22
+ {
23
+ "name" : " test4" ,
24
+ "url" : " https://test4.frog/"
25
+ }
26
+ ]
You can’t perform that action at this time.
0 commit comments