import { readFileSync } from 'fs'

import { serialize } from 'next-mdx-remote/serialize'
import { MDXRemote } from 'next-mdx-remote'

import mdComponents from '../components/mdComponents'

export default function TermsPage({ source }) {
  return (
    <MDXRemote {...source} components={{ ...mdComponents }} />
  )
}

export async function getStaticProps() {
  const source = readFileSync('./md/impressum.md', 'utf8')
  const mdxSource = await serialize(source)
  return { props: { source: mdxSource } }
}
