-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathlayout.tsx
More file actions
35 lines (31 loc) · 805 Bytes
/
Copy pathlayout.tsx
File metadata and controls
35 lines (31 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import getPosts from '@lib/get-posts'
import { Metadata } from 'next'
import { ReactNode } from 'react'
export async function generateStaticParams() {
const posts = await getPosts()
return posts.map((post) => ({ slug: post.slug }))
}
export const generateMetadata = async (props: {
params: Promise<{
slug: string
}>
}): Promise<Metadata> => {
const params = await props.params
const post = (await getPosts()).find((p) => p?.slug === params.slug)
return {
title: post?.title,
description: post?.description,
alternates: {
canonical: `https://maxleiter.com/blog/${params.slug}`,
},
}
}
export default async function PostLayout(props: {
children: ReactNode
params: Promise<{
slug: string
}>
}) {
const { children } = props
return <>{children}</>
}