Skip to content

Commit b1c930a

Browse files
committed
feat: use assets/blog for blog.data.json
1 parent 320953d commit b1c930a

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ next-env.d.ts
4242

4343
.turbo
4444

45-
/src/app/blog/data.json
46-
/src/research-blog.data.json
45+
/src/app/blog/[blogId]/data.json
46+
/src/assets/blog/main.data.json
47+
/src/assets/blog/research.data.json

scripts/download-blog-posts.data.json.mjs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
import fs from "fs"
1+
import fs from "node:fs"
22
import 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

415
const 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

src/app/blog/[blogId]/detail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import remarkMath from "remark-math"
1212
import { Box, Typography } from "@mui/material"
1313
import { styled } from "@mui/system"
1414

15+
import blogSource from "@/assets/blog/main.data.json"
1516
import LoadingPage from "@/components/LoadingPage"
1617
import { LANGUAGE_MAP } from "@/constants"
1718
import useCheckViewport from "@/hooks/useCheckViewport"
@@ -20,7 +21,6 @@ import { filterBlogsByLanguage } from "@/utils"
2021

2122
import Articles from "./articles"
2223
import TOC from "./components/tableOfContents"
23-
import blogSource from "./data.json"
2424

2525
const BlogContainer = styled(Box)(
2626
({ theme }) => `

src/app/blog/[blogId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import blogSource from "@/assets/blog/main.data.json"
12
import { genMeta } from "@/utils/route"
23

3-
import blogSource from "./data.json"
44
import Detail from "./detail"
55

66
export const generateMetadata = genMeta(({ params }) => {

src/app/blog/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import { Tune as TuneIcon } from "@mui/icons-material"
88
import { Box, Modal, Typography } from "@mui/material"
99
import { styled } from "@mui/system"
1010

11+
import blogSource from "@/assets/blog/main.data.json"
1112
import ArticleCard from "@/components/ArticleCard"
1213
import SectionWrapper from "@/components/SectionWrapper"
1314
import { LANGUAGE_MAP, getBlogCategoryList, getBlogSortList } from "@/constants"
1415
import useCheckViewport from "@/hooks/useCheckViewport"
1516
import useUserLanguage from "@/hooks/useUserLanguage"
1617
import { filterBlogsByLanguage } from "@/utils"
1718

18-
import blogSource from "./[blogId]/data.json"
19-
2019
const BlogContainer = styled(Box)(({ theme }) => ({
2120
padding: "0 6rem 14rem",
2221
[theme.breakpoints.down("md")]: {

src/app/ecosystem/Highlights/HighlightList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Swiper, SwiperSlide } from "swiper/react"
33

44
import { styled } from "@mui/system"
55

6-
import Data from "@/app/blog/[blogId]/data.json"
6+
import Data from "@/assets/blog/main.data.json"
77
import useCheckViewport from "@/hooks/useCheckViewport"
88

99
import BlogCard from "./Card"

0 commit comments

Comments
 (0)