Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nextjs markdown

// pages/index.js

import { MDXProvider } from '@mdx-js/react';
import Image from 'next/image';
import { Heading, Text, Pre, Code, Table } from '../components';

const ResponsiveImage = (props) => (
  <Image alt={props.alt} layout="responsive" {...props} />
);

const components = {
  img: ResponsiveImage,
  h1: Heading.H1,
  h2: Heading.H2,
  p: Text,
  code: Pre,
  inlineCode: Code,
};

export default function Post(props) {
  return (
    <MDXProvider components={components}>
      <main {...props} />
    </MDXProvider>
  );
}
Source by nextjs.org #
 
PREVIOUS NEXT
Tagged: #nextjs #markdown
ADD COMMENT
Topic
Name
2+6 =