Skip to content

Commit

Permalink
Merge pull request #1378 from scroll-tech/research-blog
Browse files Browse the repository at this point in the history
feat(blog): add research-blog.data.json
  • Loading branch information
Holybasil authored Dec 30, 2024
2 parents 91496a0 + b1c930a commit 9dbd833
Show file tree
Hide file tree
Showing 28 changed files with 31 additions and 7,027 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ next-env.d.ts

.turbo

/src/app/blog/data.json
/src/app/blog/[blogId]/data.json
/src/assets/blog/main.data.json
/src/assets/blog/research.data.json
29 changes: 24 additions & 5 deletions scripts/download-blog-posts.data.json.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import fs from "fs"
import fs from "node:fs"
import fetch from "node-fetch"
import path from "node:path"

import { fileURLToPath } from "url"

const __dirname = path.dirname(fileURLToPath(import.meta.url))

const blogAssetsDir = path.join(__dirname, "..", "src", "assets", "blog")

if (!fs.existsSync(blogAssetsDir)) {
fs.mkdirSync(blogAssetsDir, { recursive: true })
}

const isMainnet = process.env.NEXT_PUBLIC_SCROLL_ENVIRONMENT === "Mainnet"
const POSTS_URL = `https://blog.scroll.cat/api/posts/${isMainnet ? "published" : "preview"}/data.json`

function buildPostURL(hostType) {
return `https://blog.scroll.cat/api/posts/${isMainnet ? "published" : "preview"}/${hostType}/data.json`
}

async function fetchPosts() {
await fetch(POSTS_URL, { headers: { Origin: "https://scroll.io" } })
.then(res => res.json())
.then(json => fs.writeFileSync("./src/app/blog/[blogId]/data.json", JSON.stringify(json, null, 2)))
await Promise.all([
fetch(buildPostURL("scroll.io"))
.then(res => res.json())
.then(json => fs.writeFileSync("./src/assets/blog/main.data.json", JSON.stringify(json, null, 2))),
fetch(buildPostURL("research.scroll.io"))
.then(res => res.json())
.then(json => fs.writeFileSync("./src/assets/blog/research.data.json", JSON.stringify(json, null, 2))),
])
}

fetchPosts()
Loading

0 comments on commit 9dbd833

Please sign in to comment.