github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/downloads/index.jsx (about)

     1  import fetch from 'isomorphic-unfetch'
     2  import VERSION from '../../data/version.js'
     3  import ProductDownloader from '@hashicorp/react-product-downloader'
     4  import Head from 'next/head'
     5  import HashiHead from '@hashicorp/react-head'
     6  
     7  export default function DownloadsPage({ downloadData }) {
     8    return (
     9      <div id="p-downloads" className="g-container">
    10        <HashiHead is={Head} title="Downloads | Nomad by HashiCorp" />
    11        <ProductDownloader
    12          product="Nomad"
    13          version={VERSION}
    14          downloads={downloadData}
    15          community="/resources"
    16        />
    17      </div>
    18    )
    19  }
    20  
    21  export async function getStaticProps() {
    22    return fetch(`https://releases.hashicorp.com/nomad/${VERSION}/index.json`)
    23      .then(r => r.json())
    24      .then(r => {
    25        // TODO: restructure product-downloader to run this logic internally
    26        return r.builds.reduce((acc, build) => {
    27          if (!acc[build.os]) acc[build.os] = {}
    28          acc[build.os][build.arch] = build.url
    29          return acc
    30        }, {})
    31      })
    32      .then(r => ({ props: { downloadData: r } }))
    33      .catch(() => {
    34        throw new Error(
    35          `--------------------------------------------------------
    36          Unable to resolve version ${VERSION} on releases.hashicorp.com from link
    37          <https://releases.hashicorp.com/nomad/${VERSION}/index.json>. Usually this
    38          means that the specified version has not yet been released. The downloads page
    39          version can only be updated after the new version has been released, to ensure
    40          that it works for all users.
    41          ----------------------------------------------------------`
    42        )
    43      })
    44  }