init: pusat bantuan tumbuhin
This commit is contained in:
69
app/docs/[[...slug]]/page.tsx
Normal file
69
app/docs/[[...slug]]/page.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/page';
|
||||
import { source } from '@/lib/source';
|
||||
import { getMDXComponents } from '@/mdx-components';
|
||||
import { SITE_NAME, SITE_URL } from '@/lib/site';
|
||||
|
||||
type Props = {
|
||||
params: Promise<{ slug?: string[] }>;
|
||||
};
|
||||
|
||||
export default async function Page(props: Props) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) notFound(); // status 404 yang benar
|
||||
|
||||
const MDXContent = page.data.body;
|
||||
|
||||
// Structured data (JSON-LD) untuk Google
|
||||
const jsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'TechArticle',
|
||||
headline: page.data.title,
|
||||
description: page.data.description,
|
||||
inLanguage: 'id-ID',
|
||||
mainEntityOfPage: `${SITE_URL}${page.url}`,
|
||||
publisher: { '@type': 'Organization', name: 'Tumbuhin' },
|
||||
};
|
||||
|
||||
return (
|
||||
<DocsPage toc={page.data.toc} full={page.data.full}>
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||
/>
|
||||
<DocsTitle>{page.data.title}</DocsTitle>
|
||||
<DocsDescription>{page.data.description}</DocsDescription>
|
||||
<DocsBody>
|
||||
<MDXContent components={getMDXComponents()} />
|
||||
</DocsBody>
|
||||
</DocsPage>
|
||||
);
|
||||
}
|
||||
|
||||
// Semua halaman di-generate statis saat build (terbaik untuk SEO)
|
||||
export async function generateStaticParams() {
|
||||
return source.generateParams();
|
||||
}
|
||||
|
||||
// Title, description, canonical, dan Open Graph per artikel dari front matter
|
||||
export async function generateMetadata(props: Props): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) notFound();
|
||||
|
||||
return {
|
||||
title: page.data.title,
|
||||
description: page.data.description,
|
||||
alternates: { canonical: page.url },
|
||||
openGraph: {
|
||||
type: 'article',
|
||||
url: page.url,
|
||||
title: page.data.title,
|
||||
description: page.data.description,
|
||||
siteName: SITE_NAME,
|
||||
locale: 'id_ID',
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user