---
import Layout from '~/layouts/Layout.astro'
import { releaseNotes } from '~/release-notes'
import { getStaticPaths as getI18nPaths, getLocale, getUI } from '~/utils/i18n'

const locale = getLocale(Astro)

const {
  routes: {
    releaseNotes: { slug },
  },
} = getUI(locale)

export async function getStaticPaths() {
  const i18nPaths = getI18nPaths()

  return i18nPaths.flatMap(({ params: { locale } }) => [
    ...releaseNotes.map(release => ({
      params: { slug: release.version, locale },
      props: { ...release },
    })),
    {
      params: { slug: 'latest', locale },
      props: { ...releaseNotes[0] },
    },
  ])
}

const release = Astro.props
---

<Layout title={slug.title} redirect={`/release-notes#${release.version}`}>
  <main class="flex flex-col items-center pb-52 pt-36">
    {slug.redirect.replaceAll('{version}', release.version)}
  </main>
</Layout>
