Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/app/guides/[slug]/page.tsx |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/app/guides/[slug]/page.tsx |
| Original SHA-256 | 076a84b67cb42d6a54c76d45759d8d87136213436dba293e9aa62d2e0cdbf5f6 |
| Git blob SHA | 2878b2021b686742b5d0b6fcc1d96a4fa39af4c6 |
| Reading-copy SHA-256 | 076a84b67cb42d6a54c76d45759d8d87136213436dba293e9aa62d2e0cdbf5f6 |
Recovered source transcript
Download complete source text ↓85 lines · 2.4 KB
import { Breadcrumb } from '@thedaviddias/design-system/breadcrumb'
import { getBaseUrl } from '@thedaviddias/utils/get-base-url'
import type { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { MDXRemote } from 'next-mdx-remote/rsc'
import remarkGfm from 'remark-gfm'
import { GuideHeader } from '@/components/guide-header'
import { JsonLd } from '@/components/json-ld'
import { components } from '@/components/mdx'
import { type GuideMetadata, getGuideBySlug, getGuides } from '@/lib/content-loader'
import { getRoute } from '@/lib/routes'
import { generateGuideSchema } from '@/lib/schema'
import { generateDynamicMetadata } from '@/lib/seo/seo-config'
interface GuidePageProps {
params: Promise<{
slug: string
}>
}
/**
* Generates metadata for a guide page
*/
export async function generateMetadata(props: GuidePageProps): Promise<Metadata> {
const { slug } = await props.params
const guide = await getGuideBySlug(slug)
if (!guide) {
return {}
}
return generateDynamicMetadata({
type: 'guide',
name: guide.title,
description: guide.description || `Learn about ${guide.title} in our comprehensive guide`,
slug: guide.slug,
publishedAt: guide.date,
additionalKeywords: ['guide', 'tutorial', 'how-to', 'llms.txt implementation']
})
}
/**
* Generates static params for all guide pages
*/
export async function generateStaticParams(): Promise<Awaited<GuidePageProps['params']>[]> {
const guides = await getGuides()
return guides.map((guide: GuideMetadata) => ({
slug: guide.slug
}))
}
export default async function GuidePage({ params }: GuidePageProps) {
const { slug } = await params
const guide = await getGuideBySlug(slug)
if (!guide) {
notFound()
}
const breadcrumbItems = [
{ name: 'Guides', href: getRoute('guides.list') },
{ name: guide.title, href: getRoute('guides.guide', { slug }) }
]
return (
<article className="container relative max-w-3xl py-6 lg:py-10">
<JsonLd data={generateGuideSchema(guide)} />
<Breadcrumb items={breadcrumbItems} baseUrl={getBaseUrl()} />
<GuideHeader {...guide} />
<div className="prose dark:prose-invert max-w-none">
<MDXRemote
source={guide.content || ''}
components={components}
options={{
mdxOptions: {
remarkPlugins: [remarkGfm]
}
}}
/>
</div>
</article>
)
}