Skip to content

Commit ca1f41d

Browse files
authored
Merge pull request #72 from timlrx/update-examples
update examples to next v15 and tailwind v4
2 parents b46851a + 3185a2c commit ca1f41d

File tree

16 files changed

+116
-466
lines changed

16 files changed

+116
-466
lines changed

examples/next-images/app/posts/[slug]/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import Image from 'next/image'
55

66
export const generateStaticParams = async () => allPosts.map((post) => ({ slug: post._raw.flattenedPath }))
77

8-
export const generateMetadata = ({ params }) => {
8+
export const generateMetadata = async props => {
9+
const params = await props.params;
910
const post = allPosts.find((post) => post._raw.flattenedPath === params.slug)
1011
return { title: post.title }
1112
}
1213

13-
const PostLayout = ({ params }: { params: { slug: string } }) => {
14+
const PostLayout = async (props: { params: Promise<{ slug: string }> }) => {
15+
const params = await props.params;
1416
const post = allPosts.find((post) => post._raw.flattenedPath === params.slug)
1517

1618
const Content = getMDXComponent(post.body.code)

examples/next-images/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

examples/next-images/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
},
1010
"dependencies": {
1111
"contentlayer2": "latest",
12-
"date-fns": "3.6.0",
13-
"next": "^14.1.0",
12+
"date-fns": "4.1.0",
13+
"next": "^15.2.4",
1414
"next-contentlayer2": "latest",
15-
"react": "^18.2.0",
16-
"react-dom": "^18.2.0"
15+
"react": "^19.1.0",
16+
"react-dom": "^19.1.0"
1717
},
1818
"devDependencies": {
19-
"@types/react": "18.2.14",
20-
"autoprefixer": "^10.4.14",
19+
"@tailwindcss/postcss": "4.0.17",
20+
"@types/react": "19.0.12",
2121
"postcss": "^8.4.24",
22-
"tailwindcss": "^3.3.2",
22+
"tailwindcss": "4.0.17",
2323
"typescript": "^5.5.0"
2424
}
2525
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22
plugins: {
3-
tailwindcss: {},
4-
autoprefixer: {},
3+
'@tailwindcss/postcss': {},
54
},
65
}

examples/next-images/styles/globals.css

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1-
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700&display=swap");
1+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700&display=swap')
2+
layer(base);
23

3-
@tailwind base;
4-
@tailwind components;
5-
@tailwind utilities;
4+
@import 'tailwindcss';
5+
6+
@theme {
7+
--font-sans:
8+
Inter, ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',
9+
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
10+
}
11+
12+
/*
13+
The default border color has changed to `currentColor` in Tailwind CSS v4,
14+
so we've added these compatibility styles to make sure everything still
15+
looks the same as it did with Tailwind CSS v3.
16+
17+
If we ever want to remove these styles, we need to add an explicit border
18+
color utility to any element that depends on these defaults.
19+
*/
20+
@layer base {
21+
*,
22+
::after,
23+
::before,
24+
::backdrop,
25+
::file-selector-button {
26+
border-color: var(--color-gray-200, currentColor);
27+
}
28+
}
629

730
p {
831
@apply mb-4;

examples/next-images/tailwind.config.js

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

examples/next-rsc-dynamic/app/[...slug]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { allPosts } from 'contentlayer/generated'
22

33
export const generateStaticParams = async () => allPosts.map((post) => ({ slug: post._raw.flattenedPath.split('/') }))
44

5-
const PostLayout = async ({ params }: { params: { slug: string[]; tag: string } }) => {
5+
const PostLayout = async (props: { params: Promise<{ slug: string[]; tag: string }> }) => {
6+
const params = await props.params;
67
const slug = params.slug.join('/')
78
const post = allPosts.find((post) => post._raw.flattenedPath === slug)
89

examples/next-rsc-dynamic/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Link from 'next/link'
2-
import { allPosts, Post } from 'contentlayer/generated'
2+
import { allPosts } from 'contentlayer/generated'
33

4-
export default async function Home({ params }: { params: { tag: string } }) {
4+
export default async function Home() {
55
return (
66
<div className="py-8 mx-auto max-w-xl">
77
<h1 className="mb-8 text-3xl font-bold text-center">Next.js docs</h1>

examples/next-rsc-dynamic/app/v/[tag]/[...slug]/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { fetchContent } from 'contentlayer/generated'
22

3-
export const generateMetadata = async ({ params }: { params: { tag: string; slug: string[] } }) => {
3+
export const generateMetadata = async (props: { params: Promise<{ tag: string; slug: string[] }> }) => {
4+
const params = await props.params;
45
const contentResult = await fetchContent(params.tag)
56

67
if (contentResult._tag === 'Error') {
@@ -21,7 +22,8 @@ export const generateMetadata = async ({ params }: { params: { tag: string; slug
2122
}
2223
}
2324

24-
const PostLayout = async ({ params }: { params: { slug: string[]; tag: string } }) => {
25+
const PostLayout = async (props: { params: Promise<{ slug: string[]; tag: string }> }) => {
26+
const params = await props.params;
2527
const contentResult = await fetchContent(params.tag)
2628

2729
if (contentResult._tag === 'Error') {

examples/next-rsc-dynamic/app/v/[tag]/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import Link from 'next/link'
22
import { compareDesc, format, parseISO } from 'date-fns'
33
import { fetchContent, Post } from 'contentlayer/generated'
44

5-
export default async function Home({ params }: { params: { tag: string } }) {
5+
export default async function Home(props: { params: Promise<{ tag: string }> }) {
6+
const params = await props.params;
67
const contentResult = await fetchContent(params.tag)
78

89
if (contentResult._tag === 'Error') {
@@ -17,16 +18,15 @@ export default async function Home({ params }: { params: { tag: string } }) {
1718
const { allPosts } = contentResult.data
1819

1920
return (
20-
<div className="py-8 mx-auto max-w-xl">
21+
(<div className="py-8 mx-auto max-w-xl">
2122
<h1 className="mb-8 text-3xl font-bold text-center">Next.js docs</h1>
2223
<p className="">Branch/Tag: {params.tag}</p>
23-
2424
{allPosts.map((post, idx) => (
25-
<div key={idx}>
25+
(<div key={idx}>
2626
<Link href={'v/' + params.tag + '/' + post.url}>{post.url}</Link>
27-
</div>
27+
</div>)
2828
// <PostCard key={idx} {...post} />
2929
))}
30-
</div>
31-
)
30+
</div>)
31+
);
3232
}

0 commit comments

Comments
 (0)