diff --git a/website/pages/other-downloads/nightly-downloads.tsx b/website/pages/other-downloads/nightly-downloads.tsx index d8ba07941..4ca0695b5 100644 --- a/website/pages/other-downloads/nightly-downloads.tsx +++ b/website/pages/other-downloads/nightly-downloads.tsx @@ -11,20 +11,36 @@ import { Tr, HStack, } from "@chakra-ui/react"; +import { octokit } from "configurations/ocotokit"; +import { GetServerSideProps, NextPage } from "next"; // import { GridMultiplexAd } from "components/special"; import NavLink from "next/link"; +import { ReleaseResponse } from "./stable-downloads"; -const baseURL = - "https://nightly.link/KRTirtho/spotube/workflows/spotube-nightly/build/"; +type NightlyProps = ReleaseResponse; + +export const getServerSideProps: GetServerSideProps =async () =>{ + const { data } = await octokit.repos.getReleaseByTag({ + owner: "KRTirtho", + repo: "spotube", + tag: "nightly", + }); + return { + props: { + tag_name: data.tag_name, + id: data.id, + body: data.body, + assets: data.assets.map((asset) => ({ + id: asset.id, + name: asset.name, + browser_download_url: asset.browser_download_url, + })), + } + } +} -const DownloadLinks = Object.freeze({ - Linux: baseURL + "Spotube-Linux-Bundle.zip", - Android: baseURL + "Spotube-Android-Bundle.zip", - Windows: baseURL + "Spotube-Windows-Bundle.zip", - MacOS: baseURL + "Spotube-Macos-Bundle.zip", -}); -function NightlyDownloads() { +const NightlyDownloads: NextPage = (props)=> { return ( <> @@ -57,19 +73,24 @@ function NightlyDownloads() { py="2" w="100%" > - {Object.entries(DownloadLinks).map(([platform, url]) => { - const segments = url.split("/"); + {Object.entries(props.assets).map(([_, { name, id, browser_download_url}], i) => { + const segments = name.split("-"); + const platform = segments[1]; + const executable = segments[segments.length - 1].split(".")[1]; return ( - - {platform} + + + {platform}{" "} + ({executable}) + - {segments.at(segments.length - 1)?.replace("build", "")} + {name} ); diff --git a/website/pages/other-downloads/stable-downloads.tsx b/website/pages/other-downloads/stable-downloads.tsx index 427e9128c..9899a1bdc 100644 --- a/website/pages/other-downloads/stable-downloads.tsx +++ b/website/pages/other-downloads/stable-downloads.tsx @@ -29,7 +29,7 @@ enum AssetTypes { android = "android", } -type ReleaseResponse = { +export type ReleaseResponse = { id: number; body: string | null | undefined; tag_name: string; @@ -38,10 +38,10 @@ type ReleaseResponse = { name: string; browser_download_url: string; }[]; -}[]; +}; type Props = { - data: ReleaseResponse; + data: ReleaseResponse[]; }; export const getServerSideProps: GetServerSideProps = async ({ @@ -55,7 +55,7 @@ export const getServerSideProps: GetServerSideProps = async ({ owner: "KRTirtho", repo: "spotube", }); - const releaseResponse: ReleaseResponse = data.map((data) => { + const releaseResponse: ReleaseResponse[] = data.map((data) => { return { tag_name: data.tag_name, id: data.id,