import { readFileSync } from 'fs'

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

import mdComponents from '../components/mdComponents'

import Layout from '../components/layout'

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

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