Skip to content

Commit

Permalink
perf: static rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Sep 30, 2024
1 parent 99ead50 commit dcc56b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 7 additions & 1 deletion app/[locale]/(main)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { unstable_setRequestLocale } from "next-intl/server";
import ServerList from "../../../components/ServerList";
import ServerOverview from "../../../components/ServerOverview";

export default function Home() {
export default function Home({
params: { locale },
}: {
params: { locale: string };
}) {
unstable_setRequestLocale(locale);
return (
<div className="mx-auto grid w-full max-w-5xl gap-4 md:gap-6">
<ServerOverview />
Expand Down
13 changes: 10 additions & 3 deletions app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Inter as FontSans } from "next/font/google";
import { ThemeProvider } from "next-themes";
import { Viewport } from "next";
import { cn } from "@/lib/utils";
import { locales } from "@/i18n-metadata";
import { unstable_setRequestLocale } from "next-intl/server";

const fontSans = FontSans({
subsets: ["latin"],
Expand All @@ -35,7 +37,10 @@ export const viewport: Viewport = {
userScalable: false,
};

export const dynamic = "force-static";
// export const dynamic = "force-static";
export async function generateStaticParams() {
return locales.map((locale) => ({ locale }));
}

export default function LocaleLayout({
children,
Expand All @@ -44,12 +49,14 @@ export default function LocaleLayout({
children: React.ReactNode;
params: { locale: string };
}) {
unstable_setRequestLocale(locale);

const messages = useMessages();
return (
<html lang={locale} suppressHydrationWarning>
{/* <head>
<head>
<PublicEnvScript />
</head> */}
</head>
<body
className={cn(
"min-h-screen bg-background font-sans antialiased",
Expand Down

0 comments on commit dcc56b4

Please sign in to comment.