perf: use static page generation

This commit is contained in:
skinmaker1345 2024-10-13 01:16:31 +09:00
parent 816084af3f
commit 21dabec830
4 changed files with 9 additions and 8 deletions

View File

@ -65,12 +65,12 @@ const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
) )
} }
export const getServerSideProps = async () => { export const getStaticProps = async () => {
const votes = await Query.get.list.votes.load(1) const votes = await Query.get.list.votes.load(1)
const newBots = await Query.get.list.new.load(1) const newBots = await Query.get.list.new.load(1)
const trusted = await Query.get.list.trusted.load(1) const trusted = await Query.get.list.trusted.load(1)
return { props: { votes, newBots, trusted } } return { props: { votes, newBots, trusted }, revalidate: 60 }
} }
interface IndexProps { interface IndexProps {

View File

@ -49,11 +49,11 @@ const Index: NextPage<IndexProps> = ({ bots, servers }) => {
) )
} }
export const getServerSideProps = async () => { export const getStaticProps = async () => {
const bots = await Query.get.list.votes.load(1) const bots = await Query.get.list.votes.load(1)
const servers = await Query.get.serverList.votes.load(1) const servers = await Query.get.serverList.votes.load(1)
return { props: { bots, servers } } return { props: { bots, servers }, revalidate: 60 }
} }
interface IndexProps { interface IndexProps {

View File

@ -1,4 +1,4 @@
import { GetServerSideProps, NextPage } from 'next' import { GetStaticProps, NextPage } from 'next'
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
import { User } from '@types' import { User } from '@types'
@ -87,11 +87,12 @@ const Security: NextPage<SecurityProps> = ({ bugReports }) => {
) )
} }
export const getServerSideProps: GetServerSideProps<SecurityProps> = async () => { export const getStaticProps: GetStaticProps<SecurityProps> = async () => {
return { return {
props: { props: {
bugReports: await Promise.all(BUG_REPORTERS.map((u) => get.user.load(u))), bugReports: await Promise.all(BUG_REPORTERS.map((u) => get.user.load(u))),
}, },
revalidate: 60,
} }
} }

View File

@ -47,11 +47,11 @@ const ServerIndex: NextPage<ServerIndexProps> = ({ votes, trusted }) => {
) )
} }
export const getServerSideProps = async () => { export const getStaticProps = async () => {
const votes = await Query.get.serverList.votes.load(1) const votes = await Query.get.serverList.votes.load(1)
const trusted = await Query.get.serverList.trusted.load(1) const trusted = await Query.get.serverList.trusted.load(1)
return { props: { votes, trusted } } return { props: { votes, trusted }, revalidate: 60 }
} }
interface ServerIndexProps { interface ServerIndexProps {