How to Use Your README.md on Your Project’s Docs Page
Originally published on Aug 23, 2020
You have a project. You want to make a Docs Page. You already wrote documentation in
. Do you need to have two copies of your ReadMe? Heck no!README.md
Let’s start by cloning the Next.js MDX example. Note, you could do this same thing with Gatsby, Create React App or anything that supports MDX.
npx create-next-app --example with-mdx with-mdx-app
Next, we create a page at
. Using MDXProvider, we can importpages/docs.js
and drop it on the page.README.md
import { MDXProvider } from "@mdx-js/react"import ReadMe from "../README.md"const Docs = () => (<MDXProvider><ReadMe /></MDXProvider>)export default Docs
Do
, go tonpm run dev
and there’s your README content.localhost:3000/docs
Do a
, hit return/enter a bunch of times and your docs page is live. See for example readme-as-project-docs.vercel.app/docsvercel deploy