smooth-doc in Nextjs implementation
NextJS Smooth Doc is a minimal doc generator based on Next.js and mdx. It was migrated from smooth DOC in just 4 days in order to compare the framework difference. According to the author, using Next.js is more enjoyable and easy to implement compared to Gatsby.js.
To install NextJS Smooth Doc, follow these steps:
npx create-next-app my-docs
cd my-docs
npm install next-mdx-remote @mdx-js/react
Create a new file called docs.mdx in the pages directory and add your documentation content.
Edit the pages/index.js file and add the following code to retrieve and render the docs.mdx file:
import { getMdxNode } from 'next-mdx-remote';
import { MDXRemote } from 'next-mdx-remote';
import DocsLayout from '../components/DocsLayout';
import { getContent } from '../lib/docs';
export default function Home({ mdxSource }) {
return (
<DocsLayout>
<MDXRemote {...mdxSource} components={{/**/}} />
</DocsLayout>
);
}
export async function getStaticProps() {
const content = await getContent();
const mdxNode = getMdxNode(content);
return {
props: {
mdxSource: mdxNode
},
};
}
npm run dev
http://localhost:3000.NextJS Smooth Doc is a minimal documentation generator based on Next.js and mdx. It offers an easy-to-implement approach for generating documentation and has been successfully migrated from smooth DOC to Next.js in just a few days. The framework comparison indicates that implementing Next.js for documentation is more enjoyable.