import { translate } from '@edgeandnode/gds'
import { buildDynamicMDX } from 'nextra/remote'

import { supportedLocales, translations } from '@/i18n'
import PageNotFound from '@/PageNotFound'

export const getStaticPaths = () => {
  return {
    paths: supportedLocales.map((locale) => ({
      params: { locale, 404: ['404'] },
    })),
    fallback: false,
  }
}

export const getStaticProps = async ({ params: { locale } }) => {
  const t = (key) => translate(translations, locale, key)
  const rawMdx = `---
title: ${t('global.notFound.title')}
hideTableOfContents: true
hideContentHeader: true
hideContentFooter: true
unwrapContent: true
---`
  const mdx = await buildDynamicMDX(rawMdx, { codeHighlight: false })
  const { pageMap } = await import(`.next/static/chunks/nextra-page-map-${locale}.mjs`)
  return {
    props: {
      ...mdx,
      __nextra_pageMap: pageMap,
    },
  }
}

<PageNotFound />
