open-nomad/website/pages/downloads/index.jsx

41 lines
1.4 KiB
React
Raw Normal View History

2020-06-01 21:48:25 +00:00
import VERSION from 'data/version.js'
2020-02-06 23:45:31 +00:00
import ProductDownloader from '@hashicorp/react-product-downloader'
import Head from 'next/head'
2020-03-16 17:10:31 +00:00
import HashiHead from '@hashicorp/react-head'
2020-02-06 23:45:31 +00:00
2020-06-01 21:48:25 +00:00
export default function DownloadsPage({ releaseData }) {
2020-02-06 23:45:31 +00:00
return (
<div id="p-downloads" className="g-container">
2020-03-16 17:10:31 +00:00
<HashiHead is={Head} title="Downloads | Nomad by HashiCorp" />
2020-02-06 23:45:31 +00:00
<ProductDownloader
product="Nomad"
version={VERSION}
2020-06-01 21:48:25 +00:00
releaseData={releaseData}
community="/resources"
prerelease={{
type: 'Beta',
name: 'v1.0.0',
version: '1.0.0-beta2'
}}
2020-02-06 23:45:31 +00:00
/>
</div>
)
}
export async function getStaticProps() {
2020-02-06 23:45:31 +00:00
return fetch(`https://releases.hashicorp.com/nomad/${VERSION}/index.json`)
2020-06-01 21:48:25 +00:00
.then((res) => res.json())
.then((releaseData) => ({ props: { releaseData } }))
.catch(() => {
throw new Error(
`--------------------------------------------------------
Unable to resolve version ${VERSION} on releases.hashicorp.com from link
<https://releases.hashicorp.com/nomad/${VERSION}/index.json>. Usually this
means that the specified version has not yet been released. The downloads page
version can only be updated after the new version has been released, to ensure
that it works for all users.
----------------------------------------------------------`
)
})
2020-02-06 23:45:31 +00:00
}