open-vault/website/pages/downloads/index.jsx
Calvin Leung Huang e9ff1dc23a
website: add alert box for 1.4.0-beta1 (#8400)
* website: add alert box for 1.4.0-beta1

* fix prerelease notification

Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>
2020-02-20 16:46:31 -08:00

39 lines
1.1 KiB
JavaScript

import fetch from 'isomorphic-unfetch'
import { VERSION } from '../../data/version.js'
import ProductDownloader from '@hashicorp/react-product-downloader'
import Head from 'next/head'
export default function DownloadsPage({ downloadData }) {
return (
<div id="p-downloads" className="g-container">
<Head>
<title key="title">Downloads | Vault by HashiCorp</title>
</Head>
<ProductDownloader
product="Vault"
version={VERSION}
downloads={downloadData}
prerelease={{
type: 'beta release',
name: '1.4.0',
version: '1.4.0-beta1'
}}
/>
</div>
)
}
export async function unstable_getStaticProps() {
return fetch(`https://releases.hashicorp.com/vault/${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 } }))
}