From b7b8b55e0004eb13815ba2febb23191e98368b89 Mon Sep 17 00:00:00 2001 From: skinmaker1345 Date: Sun, 13 Oct 2024 00:48:00 +0900 Subject: [PATCH] perf: use static site generation --- pages/bots/index.tsx | 4 ++-- pages/index.tsx | 4 ++-- pages/security.tsx | 5 +++-- pages/servers/index.tsx | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pages/bots/index.tsx b/pages/bots/index.tsx index 55519be8a4..64721d9781 100644 --- a/pages/bots/index.tsx +++ b/pages/bots/index.tsx @@ -65,12 +65,12 @@ const Index: NextPage = ({ votes, newBots, trusted }) => { ) } -export const getServerSideProps = async () => { +export const getStaticProps = async () => { 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) - return { props: { votes, newBots, trusted } } + return { props: { votes, newBots, trusted }, revalidate: 60 } } interface IndexProps { diff --git a/pages/index.tsx b/pages/index.tsx index f14e34ec22..6b7ba75755 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -49,11 +49,11 @@ const Index: NextPage = ({ bots, servers }) => { ) } -export const getServerSideProps = async () => { +export const getStaticProps = async () => { const bots = await Query.get.list.votes.load(1) const servers = await Query.get.serverList.votes.load(1) - return { props: { bots, servers } } + return { props: { bots, servers }, revalidate: 60 } } interface IndexProps { diff --git a/pages/security.tsx b/pages/security.tsx index 6c367b7124..4bb861eca6 100644 --- a/pages/security.tsx +++ b/pages/security.tsx @@ -1,4 +1,4 @@ -import { GetServerSideProps, NextPage } from 'next' +import { GetServerSideProps, GetStaticProps, NextPage } from 'next' import dynamic from 'next/dynamic' import { User } from '@types' @@ -87,11 +87,12 @@ const Security: NextPage = ({ bugReports }) => { ) } -export const getServerSideProps: GetServerSideProps = async () => { +export const getStaticProps: GetStaticProps = async () => { return { props: { bugReports: await Promise.all(BUG_REPORTERS.map((u) => get.user.load(u))), }, + revalidate: 60, } } diff --git a/pages/servers/index.tsx b/pages/servers/index.tsx index 1793f33d9f..531e4cfd82 100644 --- a/pages/servers/index.tsx +++ b/pages/servers/index.tsx @@ -47,11 +47,11 @@ const ServerIndex: NextPage = ({ votes, trusted }) => { ) } -export const getServerSideProps = async () => { +export const getStaticProps = async () => { const votes = await Query.get.serverList.votes.load(1) const trusted = await Query.get.serverList.trusted.load(1) - return { props: { votes, trusted } } + return { props: { votes, trusted }, revalidate: 60 } } interface ServerIndexProps {