MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / generateMetadata

Function generateMetadata

apps/baseai.dev/src/app/learn/[section]/layout.tsx:4–56  ·  view source on GitHub ↗
({
	params
}: {
	params: Promise<{ section: string; slug: string }>;
})

Source from the content-addressed store, hash-verified

2import { FrontmatterT } from "@/types/markdown";
3
4export 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
58export default async function RootLayout({
59 children

Callers

nothing calls this directly

Calls 2

getLearnBySlugFunction · 0.90
getContentBySlugOnDevFunction · 0.85

Tested by

no test coverage detected