Skip to content

Commit

Permalink
🕹️ feat: create remote markdown page
Browse files Browse the repository at this point in the history
  • Loading branch information
restrainhalation committed Jun 21, 2024
1 parent 77f52b3 commit 1e2143b
Show file tree
Hide file tree
Showing 4 changed files with 1,471 additions and 85 deletions.
12 changes: 9 additions & 3 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import withMDX from '@next/mdx'

/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
const nextConfig = {
// Configure `pageExtensions` to include MDX files
pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
// Optionally, add any other Next.js config below
}

export default withMDX()(nextConfig)
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"lint": "next lint"
},
"dependencies": {
"@mdx-js/loader": "^3.0.1",
"@mdx-js/react": "^3.0.1",
"@next/mdx": "^14.2.4",
"@types/mdx": "^2.0.13",
"next": "14.2.4",
"next-mdx-remote": "^5.0.0",
"react": "^18",
"react-dom": "^18"
},
Expand Down
8 changes: 8 additions & 0 deletions src/app/remote/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { MDXRemote } from 'next-mdx-remote/rsc'

export default async function RemoteMdxPage() {
// MDX text - can be from a local file, database, CMS, fetch, anywhere...
const res = await fetch('https://raw.githubusercontent.com/restrainhalation/cw-the-book-of-devil-excerpt/main/README.md')
const markdown = await res.text()
return <MDXRemote source={markdown} />
}
Loading

0 comments on commit 1e2143b

Please sign in to comment.