Skip to content

Commit

Permalink
#16 Первая страница исправлена под contentlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
khusamov committed Aug 20, 2023
1 parent d54eead commit eb76655
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const Post = defineDocumentType(
{
name: 'Post',
filePathPattern: `articles/**/*.mdx`,
contentType: 'mdx',
fields: {
title: {
type: 'string',
Expand Down
14 changes: 10 additions & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import {importArticle} from '@/functions/importArticle'
import {useMDXComponent} from 'next-contentlayer/hooks'
import {allPosts, Post} from 'contentlayer/generated'

export default async function Page() {
const Article = (await importArticle('_index')).default
export default async function() {
const rootPost = allPosts.find(post => post.url === '/articles/_index')
return (
<main>
<Article/>
{rootPost && <PostComponent post={rootPost}/>}
</main>
)
}

function PostComponent({post}: {post: Post}) {
const Post = useMDXComponent(post.body.code)
return <Post/>
}

0 comments on commit eb76655

Please sign in to comment.