Skip to content

Commit dae36eb

Browse files
committed
fix: build crashes upon rendering static pages
1 parent 831b025 commit dae36eb

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

pages/bots/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dynamic from 'next/dynamic'
44
import { Bot, List } from '@types'
55
import * as Query from '@utils/Query'
66
import LongButton from '@components/LongButton'
7+
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
78

89
const Advertisement = dynamic(() => import('@components/Advertisement'))
910
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
@@ -66,6 +67,21 @@ const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
6667
}
6768

6869
export const getStaticProps = async () => {
70+
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
71+
const list = {
72+
totalPage: 1,
73+
currentPage: 1,
74+
data: [],
75+
}
76+
return {
77+
props: {
78+
votes: list,
79+
newBots: list,
80+
trusted: list,
81+
},
82+
revalidate: 1,
83+
}
84+
}
6985
const votes = await Query.get.list.votes.load(1)
7086
const newBots = await Query.get.list.new.load(1)
7187
const trusted = await Query.get.list.trusted.load(1)

pages/index.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import dynamic from 'next/dynamic'
33

44
import { Bot, List, Server } from '@types'
55
import * as Query from '@utils/Query'
6+
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
67

78
const Advertisement = dynamic(() => import('@components/Advertisement'))
89
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
@@ -50,6 +51,20 @@ const Index: NextPage<IndexProps> = ({ bots, servers }) => {
5051
}
5152

5253
export const getStaticProps = async () => {
54+
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
55+
const list = {
56+
totalPage: 1,
57+
currentPage: 1,
58+
data: [],
59+
}
60+
return {
61+
props: {
62+
bots: list,
63+
servers: list,
64+
},
65+
revalidate: 1,
66+
}
67+
}
5368
const bots = await Query.get.list.votes.load(1)
5469
const servers = await Query.get.serverList.votes.load(1)
5570

pages/security.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dynamic from 'next/dynamic'
44
import { User } from '@types'
55
import { BUG_REPORTERS, BUG_REPORT_GROUPS } from '@utils/Constants'
66
import { get } from '@utils/Query'
7+
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
78

89
const Docs = dynamic(() => import('@components/Docs'))
910
const DiscordAvatar = dynamic(() => import('@components/DiscordAvatar'))
@@ -88,6 +89,14 @@ const Security: NextPage<SecurityProps> = ({ bugReports }) => {
8889
}
8990

9091
export const getStaticProps: GetStaticProps<SecurityProps> = async () => {
92+
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
93+
return {
94+
props: {
95+
bugReports: [],
96+
},
97+
revalidate: 1,
98+
}
99+
}
91100
return {
92101
props: {
93102
bugReports: await Promise.all(BUG_REPORTERS.map((u) => get.user.load(u))),

pages/servers/index.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import dynamic from 'next/dynamic'
33

44
import { Server, List } from '@types'
55
import * as Query from '@utils/Query'
6+
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
67

78
const Advertisement = dynamic(() => import('@components/Advertisement'))
89
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
@@ -48,6 +49,20 @@ const ServerIndex: NextPage<ServerIndexProps> = ({ votes, trusted }) => {
4849
}
4950

5051
export const getStaticProps = async () => {
52+
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
53+
const list = {
54+
totalPage: 1,
55+
currentPage: 1,
56+
data: [],
57+
}
58+
return {
59+
props: {
60+
votes: list,
61+
trusted: list,
62+
},
63+
revalidate: 1,
64+
}
65+
}
5166
const votes = await Query.get.serverList.votes.load(1)
5267
const trusted = await Query.get.serverList.trusted.load(1)
5368

0 commit comments

Comments
 (0)