Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sistematico committed Dec 13, 2024
1 parent 654bfc9 commit 7635336
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { CustomMDX } from '../../components/mdx'
import { formatDate, getBlogPosts } from '../../posts/utils'
import { baseUrl } from '../../sitemap'

interface PageProps {
params: Promise<{
slug: string;
}>;
}

export async function generateStaticParams() {
let posts = await getBlogPosts()

Expand All @@ -11,8 +17,10 @@ export async function generateStaticParams() {
}))
}

export async function generateMetadata({ params }: { params: { slug: string } }) {
const post = (await getBlogPosts()).find((post) => post.slug === params.slug)
export async function generateMetadata({ params }: PageProps) {
const { slug } = await params;
const posts = await getBlogPosts();
const post = posts.find((post) => post.slug === slug);
if (!post) return

let {
Expand Down Expand Up @@ -49,8 +57,12 @@ export async function generateMetadata({ params }: { params: { slug: string } })
}
}

export default async function Blog({ params }: { params: { slug: string } }) {
const post = (await getBlogPosts()).find((post) => post.slug === params.slug)
export default async function Blog({ params }: PageProps) {
// const post = (await getBlogPosts()).find((post) => post.slug === params.slug)
const { slug } = await params;
const posts = await getBlogPosts();
const post = posts.find((post) => post.slug === slug);

if (!post) notFound()

return (
Expand Down

0 comments on commit 7635336

Please sign in to comment.