Skip to content

Instantly share code, notes, and snippets.

@albertBarsegyan
Created October 3, 2021 16:42
Show Gist options
  • Save albertBarsegyan/0e7681c44b7ab1483b007a14949bd6a2 to your computer and use it in GitHub Desktop.
Save albertBarsegyan/0e7681c44b7ab1483b007a14949bd6a2 to your computer and use it in GitHub Desktop.
import { MDXRemote } from 'next-mdx-remote';
import getDocBySlug from '../src/services/getDocBySlug.mjs';
import Image from 'next/image';
import { serialize } from 'next-mdx-remote/serialize';
export default function Blog({ content, meta }) {
const components = {
Image,
};
return (
<div>
<MDXRemote components={components} {...content} />
</div>
);
}
export async function getStaticProps({ locale }) {
const { content, meta } = getDocBySlug('blog', locale);
const mdxSource = await serialize(content);
return {
props: {
content: mdxSource,
meta,
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment