({
params
}: {
params: Promise<{ section: string; slug: string }>;
})
| 2 | import { FrontmatterT } from "@/types/markdown"; |
| 3 | |
| 4 | export async function generateMetadata({ |
| 5 | params |
| 6 | }: { |
| 7 | params: Promise<{ section: string; slug: string }>; |
| 8 | }) { |
| 9 | const { section } = await params; |
| 10 | let frontmatter: FrontmatterT; |
| 11 | |
| 12 | if (process.env.NODE_ENV === 'production') { |
| 13 | const data = await getLearnBySlug({ |
| 14 | section: 'learn', |
| 15 | slug: section |
| 16 | }); |
| 17 | |
| 18 | frontmatter = data.frontmatter as unknown as FrontmatterT; |
| 19 | } else { |
| 20 | const { getContentBySlugOnDev } = await import('@/lib/get-content-by-slug-on-dev'); |
| 21 | |
| 22 | const data = await getContentBySlugOnDev({ |
| 23 | type: 'learn', |
| 24 | slug: section, |
| 25 | section: 'learn', |
| 26 | }); |
| 27 | |
| 28 | frontmatter = data.frontmatter; |
| 29 | } |
| 30 | |
| 31 | |
| 32 | return { |
| 33 | title: frontmatter?.title, |
| 34 | description: frontmatter?.description, |
| 35 | keywords: frontmatter?.tags, |
| 36 | openGraph: { |
| 37 | title: frontmatter?.title, |
| 38 | description: frontmatter?.description, |
| 39 | url: frontmatter?.url, |
| 40 | images: [ |
| 41 | { |
| 42 | url: frontmatter?.imageUrl, |
| 43 | alt: frontmatter?.title |
| 44 | } |
| 45 | ] |
| 46 | }, |
| 47 | twitter: { |
| 48 | title: frontmatter?.title, |
| 49 | description: frontmatter?.description, |
| 50 | image: frontmatter?.imageUrl |
| 51 | }, |
| 52 | alternates: { |
| 53 | canonical: frontmatter?.url |
| 54 | } |
| 55 | }; |
| 56 | } |
| 57 | |
| 58 | export default async function RootLayout({ |
| 59 | children |
nothing calls this directly
no test coverage detected