fix: build crashes upon rendering static pages

This commit is contained in:
skinmaker1345 2024-10-13 01:50:24 +09:00
parent 831b025d76
commit dae36ebd0b
4 changed files with 55 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import dynamic from 'next/dynamic'
import { Bot, List } from '@types'
import * as Query from '@utils/Query'
import LongButton from '@components/LongButton'
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
const Advertisement = dynamic(() => import('@components/Advertisement'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
@ -66,6 +67,21 @@ const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
}
export const getStaticProps = async () => {
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
const list = {
totalPage: 1,
currentPage: 1,
data: [],
}
return {
props: {
votes: list,
newBots: list,
trusted: list,
},
revalidate: 1,
}
}
const votes = await Query.get.list.votes.load(1)
const newBots = await Query.get.list.new.load(1)
const trusted = await Query.get.list.trusted.load(1)

View File

@ -3,6 +3,7 @@ import dynamic from 'next/dynamic'
import { Bot, List, Server } from '@types'
import * as Query from '@utils/Query'
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
const Advertisement = dynamic(() => import('@components/Advertisement'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
@ -50,6 +51,20 @@ const Index: NextPage<IndexProps> = ({ bots, servers }) => {
}
export const getStaticProps = async () => {
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
const list = {
totalPage: 1,
currentPage: 1,
data: [],
}
return {
props: {
bots: list,
servers: list,
},
revalidate: 1,
}
}
const bots = await Query.get.list.votes.load(1)
const servers = await Query.get.serverList.votes.load(1)

View File

@ -4,6 +4,7 @@ import dynamic from 'next/dynamic'
import { User } from '@types'
import { BUG_REPORTERS, BUG_REPORT_GROUPS } from '@utils/Constants'
import { get } from '@utils/Query'
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
const Docs = dynamic(() => import('@components/Docs'))
const DiscordAvatar = dynamic(() => import('@components/DiscordAvatar'))
@ -88,6 +89,14 @@ const Security: NextPage<SecurityProps> = ({ bugReports }) => {
}
export const getStaticProps: GetStaticProps<SecurityProps> = async () => {
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
return {
props: {
bugReports: [],
},
revalidate: 1,
}
}
return {
props: {
bugReports: await Promise.all(BUG_REPORTERS.map((u) => get.user.load(u))),

View File

@ -3,6 +3,7 @@ import dynamic from 'next/dynamic'
import { Server, List } from '@types'
import * as Query from '@utils/Query'
import { PHASE_PRODUCTION_BUILD } from 'next/constants'
const Advertisement = dynamic(() => import('@components/Advertisement'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
@ -48,6 +49,20 @@ const ServerIndex: NextPage<ServerIndexProps> = ({ votes, trusted }) => {
}
export const getStaticProps = async () => {
if (process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD) {
const list = {
totalPage: 1,
currentPage: 1,
data: [],
}
return {
props: {
votes: list,
trusted: list,
},
revalidate: 1,
}
}
const votes = await Query.get.serverList.votes.load(1)
const trusted = await Query.get.serverList.trusted.load(1)