Skip to content

Commit

Permalink
examples: blog-starter used params without await (vercel#72327)
Browse files Browse the repository at this point in the history
### Why?

Example `blog-starter` was using `params` without awaiting.
  • Loading branch information
devjiwonchoi authored Nov 5, 2024
1 parent 2fbbca9 commit 80dbb1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 6 additions & 6 deletions examples/blog-starter/package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"private": true,
"scripts": {
"dev": "next",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start"
},
"dependencies": {
"classnames": "^2.5.1",
"date-fns": "^3.6.0",
"gray-matter": "^4.0.3",
"next": "latest",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"next": "15.0.2",
"react": "19.0.0-rc.0",
"react-dom": "19.0.0-rc.0",
"remark": "^15.0.1",
"remark-html": "^16.0.1"
},
"devDependencies": {
"@types/node": "^20.14.8",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]",
"autoprefixer": "^10.4.19",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
Expand Down
10 changes: 6 additions & 4 deletions examples/blog-starter/src/app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Header from "@/app/_components/header";
import { PostBody } from "@/app/_components/post-body";
import { PostHeader } from "@/app/_components/post-header";

export default async function Post({ params }: Params) {
export default async function Post(props: Params) {
const params = await props.params;
const post = getPostBySlug(params.slug);

if (!post) {
Expand Down Expand Up @@ -38,12 +39,13 @@ export default async function Post({ params }: Params) {
}

type Params = {
params: {
params: Promise<{
slug: string;
};
}>;
};

export function generateMetadata({ params }: Params): Metadata {
export async function generateMetadata(props: Params): Promise<Metadata> {
const params = await props.params;
const post = getPostBySlug(params.slug);

if (!post) {
Expand Down
3 changes: 2 additions & 1 deletion examples/blog-starter/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
],
"paths": {
"@/*": ["./src/*"]
}
},
"target": "ES2017"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
Expand Down

0 comments on commit 80dbb1b

Please sign in to comment.