apply async codemod

This commit is contained in:
Timothy Lin
2024-10-31 22:37:40 +08:00
parent c7c61a8609
commit 85fe09b13e
4 changed files with 14 additions and 11 deletions

View File

@ -21,11 +21,10 @@ const layouts = {
PostBanner,
}
export async function generateMetadata({
params,
}: {
params: { slug: string[] }
export async function generateMetadata(props: {
params: Promise<{ slug: string[] }>
}): Promise<Metadata | undefined> {
const params = await props.params
const slug = decodeURI(params.slug.join('/'))
const post = allBlogs.find((p) => p.slug === slug)
const authorList = post?.authors || ['default']
@ -78,7 +77,8 @@ export const generateStaticParams = async () => {
return allBlogs.map((p) => ({ slug: p.slug.split('/').map((name) => decodeURI(name)) }))
}
export default async function Page({ params }: { params: { slug: string[] } }) {
export default async function Page(props: { params: Promise<{ slug: string[] }> }) {
const params = await props.params
const slug = decodeURI(params.slug.join('/'))
// Filter out drafts in production
const sortedCoreContents = allCoreContent(sortPosts(allBlogs))

View File

@ -11,7 +11,8 @@ export const generateStaticParams = async () => {
return paths
}
export default function Page({ params }: { params: { page: string } }) {
export default async function Page(props: { params: Promise<{ page: string }> }) {
const params = await props.params
const posts = allCoreContent(sortPosts(allBlogs))
const pageNumber = parseInt(params.page as string)
const initialDisplayPosts = posts.slice(