1- import fs from "fs"
1+ import fs from "node: fs"
22import fetch from "node-fetch"
3+ import path from "node:path"
4+
5+ import { fileURLToPath } from "url"
6+
7+ const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
8+
9+ const blogAssetsDir = path . join ( __dirname , ".." , "src" , "assets" , "blog" )
10+
11+ if ( ! fs . existsSync ( blogAssetsDir ) ) {
12+ fs . mkdirSync ( blogAssetsDir , { recursive : true } )
13+ }
314
415const isMainnet = process . env . NEXT_PUBLIC_SCROLL_ENVIRONMENT === "Mainnet"
516
@@ -11,10 +22,10 @@ async function fetchPosts() {
1122 await Promise . all ( [
1223 fetch ( buildPostURL ( "scroll.io" ) )
1324 . then ( res => res . json ( ) )
14- . then ( json => fs . writeFileSync ( "./src/app /blog/[blogId]/ data.json" , JSON . stringify ( json , null , 2 ) ) ) ,
25+ . then ( json => fs . writeFileSync ( "./src/assets /blog/main. data.json" , JSON . stringify ( json , null , 2 ) ) ) ,
1526 fetch ( buildPostURL ( "research.scroll.io" ) )
1627 . then ( res => res . json ( ) )
17- . then ( json => fs . writeFileSync ( "./src/research- blog.data.json" , JSON . stringify ( json , null , 2 ) ) ) ,
28+ . then ( json => fs . writeFileSync ( "./src/assets/ blog/research .data.json" , JSON . stringify ( json , null , 2 ) ) ) ,
1829 ] )
1930}
2031
0 commit comments