2020-02-06 23:45:31 +00:00
|
|
|
import fetch from 'isomorphic-unfetch'
|
|
|
|
import VERSION from '../../data/version.js'
|
|
|
|
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
|
|
|
|
|
|
|
export default function DownloadsPage({ downloadData }) {
|
|
|
|
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}
|
|
|
|
downloads={downloadData}
|
2020-03-02 20:11:18 +00:00
|
|
|
community="/resources"
|
2020-03-25 15:14:55 +00:00
|
|
|
prerelease={{
|
|
|
|
type: 'Beta 1',
|
|
|
|
name: 'v0.11.0',
|
|
|
|
version: '0.11.0-beta1'
|
|
|
|
}}
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function unstable_getStaticProps() {
|
|
|
|
return fetch(`https://releases.hashicorp.com/nomad/${VERSION}/index.json`)
|
|
|
|
.then(r => r.json())
|
|
|
|
.then(r => {
|
|
|
|
// TODO: restructure product-downloader to run this logic internally
|
|
|
|
return r.builds.reduce((acc, build) => {
|
|
|
|
if (!acc[build.os]) acc[build.os] = {}
|
|
|
|
acc[build.os][build.arch] = build.url
|
|
|
|
return acc
|
|
|
|
}, {})
|
|
|
|
})
|
|
|
|
.then(r => ({ props: { downloadData: r } }))
|
2020-03-03 20:31:05 +00:00
|
|
|
.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
|
|
|
}
|