Skip to content

Commit 9d8df99

Browse files
committed
chore: upgrade Next.js, next-intl, and Headless UI to latest versions
1 parent 06b33b6 commit 9d8df99

File tree

11 files changed

+283
-172
lines changed

11 files changed

+283
-172
lines changed

apps/website/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ yarn dev
1313
```
1414

1515
Open http://localhost:3000 with your browser to see the result.
16+
17+
18+
For Blog Page, you can use the following command to generate the static pages:
19+
20+
```
21+
GHOST_URL=""
22+
GHOST_KEY=""
23+
```

apps/website/app/[locale]/blog/[slug]/page.tsx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CopyButton } from "@/components/ui/copy-button";
22
import { getPost, getPosts } from "@/lib/ghost";
33
import type { Metadata, ResolvingMetadata } from "next";
4-
import { getTranslations } from "next-intl/server";
4+
import { getTranslations, setRequestLocale } from "next-intl/server";
55
import Image from "next/image";
66
import Link from "next/link";
77
import { notFound } from "next/navigation";
@@ -27,7 +27,8 @@ export async function generateMetadata(
2727
{ params }: Props,
2828
parent: ResolvingMetadata,
2929
): Promise<Metadata> {
30-
const post = await getPost(params.slug);
30+
const { locale, slug } = await params;
31+
const post = await getPost(slug);
3132

3233
if (!post) {
3334
return {
@@ -36,10 +37,10 @@ export async function generateMetadata(
3637
}
3738

3839
const ogUrl = new URL(
39-
`/${params.locale}/api/og`,
40+
`/${locale}/api/og`,
4041
process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000",
4142
);
42-
ogUrl.searchParams.set("slug", params.slug);
43+
ogUrl.searchParams.set("slug", slug);
4344

4445
return {
4546
title: post.title,
@@ -69,10 +70,14 @@ export async function generateMetadata(
6970

7071
export async function generateStaticParams() {
7172
const posts = await getPosts();
73+
const locales = ["en", "fr", "zh-Hans"];
7274

73-
return posts.map((post) => ({
74-
slug: post.slug,
75-
}));
75+
return posts.flatMap((post) =>
76+
locales.map((locale) => ({
77+
locale,
78+
slug: post.slug,
79+
})),
80+
);
7681
}
7782

7883
interface CodeProps
@@ -126,13 +131,14 @@ async function CodeBlock(props: LanguageProps) {
126131
<CopyButton text={format} />
127132
<div
128133
dangerouslySetInnerHTML={{ __html: out }}
129-
className="text-sm p-4 rounded-lg bg-[#18191F]"
134+
className="text-sm p-4 rounded-lg bg-[#18191F] overflow-auto"
130135
/>
131136
</div>
132137
);
133138
}
134139
export default async function BlogPostPage({ params }: Props) {
135-
const { locale, slug } = params;
140+
const { locale, slug } = await params;
141+
// setRequestLocale(locale);
136142
const t = await getTranslations({ locale, namespace: "blog" });
137143
const post = await getPost(slug);
138144
const allPosts = await getPosts();
@@ -164,7 +170,10 @@ export default async function BlogPostPage({ params }: Props) {
164170

165171
const components: Partial<Components> = {
166172
h1: ({ node, ...props }) => (
167-
<h1 className="text-3xl text-primary font-bold mt-8 mb-4" {...props} />
173+
<h1
174+
className="text-xl md:text-2xl xl:text-3xl text-primary font-bold mt-8 mb-4"
175+
{...props}
176+
/>
168177
),
169178
h2: ({ node, ...props }) => (
170179
<h2 className="text-2xl text-primary/90 font-bold mt-6 mb-3" {...props} />
@@ -230,7 +239,7 @@ export default async function BlogPostPage({ params }: Props) {
230239
<ZoomableImage
231240
src={src || ""}
232241
alt={alt || ""}
233-
className="object-cover max-w-lg mx-auto rounded-lg border border-border"
242+
className="object-cover max-w-lg mx-auto rounded-lg border max-lg:w-64 border-border overflow-hidden"
234243
/>
235244
),
236245
code: ({ inline, className, children, ...props }: CodeProps) => {
@@ -245,7 +254,7 @@ export default async function BlogPostPage({ params }: Props) {
245254
};
246255

247256
return (
248-
<article className="container mx-auto px-4 py-12 max-w-5xl">
257+
<article className="container mx-auto px-4 pb-12 max-w-5xl">
249258
<Link
250259
href="/blog"
251260
className="inline-flex items-center mb-8 text-primary hover:text-primary/80 transition-colors"
@@ -267,7 +276,9 @@ export default async function BlogPostPage({ params }: Props) {
267276

268277
<div className=" rounded-lg p-8 shadow-lg border border-border">
269278
<header className="mb-8">
270-
<h1 className="text-4xl font-bold mb-4">{post.title}</h1>
279+
<h1 className="text-2xl md:text-3xl xl:text-4xl font-bold mb-4">
280+
{post.title}
281+
</h1>
271282
<div className="flex items-center mb-6">
272283
{post.primary_author?.profile_image && (
273284
<div className="relative h-12 w-12 rounded-full overflow-hidden mr-4">

apps/website/app/[locale]/blog/page.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getPosts, getTags } from "@/lib/ghost";
22
import type { Post } from "@/lib/ghost";
33
import { RssIcon } from "lucide-react";
44
import type { Metadata } from "next";
5-
import { getTranslations } from "next-intl/server";
5+
import { getTranslations, setRequestLocale } from "next-intl/server";
66
import Link from "next/link";
77
import { BlogPostCard } from "./components/BlogPostCard";
88
import { SearchAndFilter } from "./components/SearchAndFilter";
@@ -19,19 +19,22 @@ export const metadata: Metadata = {
1919
};
2020

2121
export default async function BlogPage({
22-
params: { locale },
22+
params,
2323
searchParams,
2424
}: {
2525
params: { locale: string };
2626
searchParams: { [key: string]: string | string[] | undefined };
2727
}) {
28+
const { locale } = await params;
29+
const searchParams2 = await searchParams;
30+
setRequestLocale(locale);
2831
const t = await getTranslations({ locale, namespace: "blog" });
2932
const posts = await getPosts();
3033
const tags = (await getTags()) as Tag[];
3134
const search =
32-
typeof searchParams.search === "string" ? searchParams.search : "";
35+
typeof searchParams2.search === "string" ? searchParams2.search : "";
3336
const selectedTag =
34-
typeof searchParams.tag === "string" ? searchParams.tag : "";
37+
typeof searchParams2.tag === "string" ? searchParams2.tag : "";
3538

3639
const filteredPosts = posts.filter((post) => {
3740
const matchesSearch =

apps/website/app/[locale]/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "react-photo-view/dist/react-photo-view.css";
44
import { Footer } from "@/components/Footer";
55
import { Header } from "@/components/Header";
66
import type { Metadata } from "next";
7+
import { setRequestLocale } from "next-intl/server";
78

89
export const metadata: Metadata = {
910
metadataBase: new URL("https://dokploy.com"),
@@ -75,6 +76,8 @@ export default async function RootLayout({
7576
children: React.ReactNode;
7677
params: { locale: string };
7778
}) {
79+
const { locale } = await params;
80+
setRequestLocale(locale);
7881
return (
7982
<div className="flex h-full flex-col">
8083
<Header />

apps/website/app/[locale]/not-found.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/website/app/[locale]/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import { Pricing } from "@/components/pricing";
77
import { SecondaryFeaturesSections } from "@/components/secondary-features";
88
import { Sponsors } from "@/components/sponsors";
99
import { StatsSection } from "@/components/stats";
10+
import { setRequestLocale } from "next-intl/server";
1011

11-
export default function Home() {
12+
export default async function Home({ params }: { params: { locale: string } }) {
13+
const { locale } = await params;
14+
setRequestLocale(locale);
1215
return (
1316
<div>
1417
<main>

apps/website/components/SlimLayout.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import { Link } from "@/i18n/routing";
2-
import { useTranslations } from "next-intl";
32

43
export function SlimLayout() {
5-
const t = useTranslations("404");
64
return (
75
<>
86
<main className="flex flex-auto items-center justify-center text-center">
97
<div>
108
<h1 className="mb-4 text-6xl font-semibold text-primary">404</h1>
11-
<p className="mb-4 text-lg text-muted-foreground">{t("title")}</p>
9+
<p className="mb-4 text-lg text-muted-foreground">Not found.</p>
1210
<p className="mt-4 text-muted-foreground">
13-
{t("des")}{" "}
11+
Go back to home
1412
<Link href="/" className="text-primary">
15-
{t("action")}
13+
Go back to home
1614
</Link>
17-
p{" "}
15+
.
1816
</p>
1917
</div>
2018
</main>

apps/website/components/secondary-features.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { useEffect, useState } from "react";
66

77
import { cn } from "@/lib/utils";
88
import { useTranslations } from "next-intl";
9-
import { Container } from "./Container";
10-
import Safari from "./ui/safari";
119

1210
const features = [
1311
{

apps/website/i18n/request.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { getRequestConfig } from "next-intl/server";
2-
import { notFound } from "next/navigation";
32
import { routing } from "./routing";
43

5-
export default getRequestConfig(async ({ locale }) => {
4+
export default getRequestConfig(async ({ requestLocale }) => {
5+
let locale = await requestLocale;
66
// Validate that the incoming `locale` parameter is valid
7-
if (!routing.locales.includes(locale as any)) notFound();
7+
if (!locale || !routing.locales.includes(locale as any)) {
8+
locale = routing.defaultLocale;
9+
}
810

911
return {
12+
locale,
1013
messages: (await import(`../locales/${locale}.json`)).default,
1114
};
1215
});

apps/website/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"browserslist": "defaults, not ie <= 11",
1414
"dependencies": {
15-
"@headlessui/react": "^1.7.17",
15+
"@headlessui/react": "^2.2.0",
1616
"@headlessui/tailwindcss": "^0.2.0",
1717
"@radix-ui/react-accordion": "^1.2.1",
1818
"@radix-ui/react-avatar": "^1.1.1",
@@ -32,8 +32,8 @@
3232
"clsx": "^2.1.0",
3333
"framer-motion": "^11.3.19",
3434
"lucide-react": "0.364.0",
35-
"next": "14.2.2",
36-
"next-intl": "^3.19.0",
35+
"next": "15.2.0",
36+
"next-intl": "^3.26.5",
3737
"react": "18.2.0",
3838
"react-dom": "18.2.0",
3939
"react-ga4": "^2.1.0",

0 commit comments

Comments
 (0)