2024-02-05 14:42:55 +00:00
|
|
|
import { Article } from '@/types/content-types'
|
|
|
|
import { getDb } from '@/utils/ContentDatabase'
|
|
|
|
import { ArticleNavLinks } from './ArticleNavLinks'
|
|
|
|
import ExampleCodeBlock from './ExampleCodeBlock'
|
|
|
|
import { Header } from './Header'
|
|
|
|
import { Mdx } from './Mdx'
|
|
|
|
import { Sidebar } from './Sidebar'
|
|
|
|
|
|
|
|
export async function ExampleDocsPage({ article }: { article: Article }) {
|
|
|
|
const db = await getDb()
|
|
|
|
const section = await db.getSection(article.sectionId)
|
|
|
|
const category = await db.getCategory(article.categoryId)
|
|
|
|
const links = await db.getArticleLinks(article)
|
|
|
|
const sidebar = await db.getSidebarContentList({
|
|
|
|
sectionId: section.id,
|
|
|
|
categoryId: category.id,
|
|
|
|
articleId: article.id,
|
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Header sectionId={section.id} />
|
2024-02-29 16:28:45 +00:00
|
|
|
<Sidebar {...sidebar} />
|
|
|
|
<main className={`main-content article article__example`}>
|
2024-02-05 14:42:55 +00:00
|
|
|
<div className="page-header">
|
|
|
|
<h1>{article.title}</h1>
|
2024-02-22 09:05:35 +00:00
|
|
|
{article.description && <p>{article.description}</p>}
|
2024-02-05 14:42:55 +00:00
|
|
|
</div>
|
2024-02-22 09:05:35 +00:00
|
|
|
{article.content && <Mdx content={article.content} />}
|
2024-02-29 16:28:45 +00:00
|
|
|
<ExampleCodeBlock
|
|
|
|
articleId={article.id}
|
|
|
|
files={{
|
|
|
|
'App.tsx': article.componentCode,
|
|
|
|
...(article.componentCodeFiles ? JSON.parse(article.componentCodeFiles) : null),
|
|
|
|
}}
|
|
|
|
activeFile={'App.tsx'}
|
|
|
|
/>
|
2024-02-05 14:42:55 +00:00
|
|
|
{links && <ArticleNavLinks links={links} />}
|
|
|
|
</main>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|