Skip to content

Commit 85fe09b

Browse files
committed
apply async codemod
1 parent c7c61a8 commit 85fe09b

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

app/blog/[...slug]/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ const layouts = {
2121
PostBanner,
2222
}
2323

24-
export async function generateMetadata({
25-
params,
26-
}: {
27-
params: { slug: string[] }
24+
export async function generateMetadata(props: {
25+
params: Promise<{ slug: string[] }>
2826
}): Promise<Metadata | undefined> {
27+
const params = await props.params
2928
const slug = decodeURI(params.slug.join('/'))
3029
const post = allBlogs.find((p) => p.slug === slug)
3130
const authorList = post?.authors || ['default']
@@ -78,7 +77,8 @@ export const generateStaticParams = async () => {
7877
return allBlogs.map((p) => ({ slug: p.slug.split('/').map((name) => decodeURI(name)) }))
7978
}
8079

81-
export default async function Page({ params }: { params: { slug: string[] } }) {
80+
export default async function Page(props: { params: Promise<{ slug: string[] }> }) {
81+
const params = await props.params
8282
const slug = decodeURI(params.slug.join('/'))
8383
// Filter out drafts in production
8484
const sortedCoreContents = allCoreContent(sortPosts(allBlogs))

app/blog/page/[page]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const generateStaticParams = async () => {
1111
return paths
1212
}
1313

14-
export default function Page({ params }: { params: { page: string } }) {
14+
export default async function Page(props: { params: Promise<{ page: string }> }) {
15+
const params = await props.params
1516
const posts = allCoreContent(sortPosts(allBlogs))
1617
const pageNumber = parseInt(params.page as string)
1718
const initialDisplayPosts = posts.slice(

app/tags/[tag]/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { genPageMetadata } from 'app/seo'
88
import { Metadata } from 'next'
99
import { notFound } from 'next/navigation'
1010

11-
export async function generateMetadata({ params }: { params: { tag: string } }): Promise<Metadata> {
11+
export async function generateMetadata(props: {
12+
params: Promise<{ tag: string }>
13+
}): Promise<Metadata> {
14+
const params = await props.params
1215
const tag = decodeURI(params.tag)
1316
return genPageMetadata({
1417
title: tag,
@@ -31,7 +34,8 @@ export const generateStaticParams = async () => {
3134
return paths
3235
}
3336

34-
export default function TagPage({ params }: { params: { tag: string } }) {
37+
export default async function TagPage(props: { params: Promise<{ tag: string }> }) {
38+
const params = await props.params
3539
const tag = decodeURI(params.tag)
3640
// Capitalize first letter and convert space to dash
3741
const title = tag[0].toUpperCase() + tag.split(' ').join('-').slice(1)

scripts/rss.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ async function generateRSS(config, allBlogs, page = 'feed.xml') {
4747

4848
if (publishPosts.length > 0) {
4949
for (const tag of Object.keys(tagData)) {
50-
const filteredPosts = allBlogs.filter((post) =>
51-
post.tags.map((t) => slug(t)).includes(tag)
52-
)
50+
const filteredPosts = allBlogs.filter((post) => post.tags.map((t) => slug(t)).includes(tag))
5351
const rss = generateRss(config, filteredPosts, `tags/${tag}/${page}`)
5452
const rssPath = path.join(outputFolder, 'tags', tag)
5553
mkdirSync(rssPath, { recursive: true })

0 commit comments

Comments
 (0)