Skip to content

Commit

Permalink
wip add test page
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrishi committed Nov 14, 2023
1 parent d09eea4 commit 1e625c6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
25 changes: 25 additions & 0 deletions app/test/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { allTests } from 'contentlayer/generated'
import { notFound } from 'next/navigation'
import type { Metadata } from 'next/types'
import { useMDXComponent } from 'next-contentlayer/hooks'

import { FancyH1 } from '@/components/headings'
import mdxComponents from '@/components/mdx-components'

export const metadata: Metadata = {
title: 'Test',
}

export default function Test() {
const testPage = allTests[0]
if (!testPage) notFound()

const MDXContent = useMDXComponent(testPage.body.code)

return (
<>
<FancyH1>{testPage.title}</FancyH1>
<MDXContent components={mdxComponents} />
</>
)
}
2 changes: 0 additions & 2 deletions pages/_test.md → content/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ I am a [link](#)

I am a [link with `code`](#)

### I am a h3 with a [link](#)


# Blockquotes
<Blockquote
Expand Down
13 changes: 12 additions & 1 deletion contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ export const Music = defineDocumentType(() => ({
contentType: 'mdx',
}))

export default makeSource({ contentDirPath: 'content', documentTypes: [Music, Post, Project] })
export const Test = defineDocumentType(() => ({
name: 'Test',
filePathPattern: 'test.md',
contentType: 'mdx',
fields: {
title: { type: 'string', required: true },
description: { type: 'string', required: true },
date: { type: 'string', required: true },
},
}))

export default makeSource({ contentDirPath: 'content', documentTypes: [Music, Post, Project, Test] })

0 comments on commit 1e625c6

Please sign in to comment.