Skip to content

Commit

Permalink
website: use new nightly release channel instead of showing nightly.l…
Browse files Browse the repository at this point in the history
…ink links
  • Loading branch information
KRTirtho committed Feb 5, 2023
1 parent a435d41 commit 576e2c6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
51 changes: 36 additions & 15 deletions website/pages/other-downloads/nightly-downloads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<NightlyProps> =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<NightlyProps> = (props)=> {
return (
<>
<VStack>
Expand Down Expand Up @@ -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 (
<HStack key={url}>
<Text w="100px">{platform}</Text>
<HStack key={id} py="2">
<Text w="200px" textTransform="capitalize">
{platform}{" "}
<chakra.span color="gray.500">({executable})</chakra.span>
</Text>
<Anchor
overflowWrap="break-word"
wordBreak="break-word"
w="full"
href={url}
href={browser_download_url}
color="blue.500"
>
{segments.at(segments.length - 1)?.replace("build", "")}
{name}
</Anchor>
</HStack>
);
Expand Down
8 changes: 4 additions & 4 deletions website/pages/other-downloads/stable-downloads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum AssetTypes {
android = "android",
}

type ReleaseResponse = {
export type ReleaseResponse = {
id: number;
body: string | null | undefined;
tag_name: string;
Expand All @@ -38,10 +38,10 @@ type ReleaseResponse = {
name: string;
browser_download_url: string;
}[];
}[];
};

type Props = {
data: ReleaseResponse;
data: ReleaseResponse[];
};

export const getServerSideProps: GetServerSideProps<Props> = async ({
Expand All @@ -55,7 +55,7 @@ export const getServerSideProps: GetServerSideProps<Props> = 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,
Expand Down

0 comments on commit 576e2c6

Please sign in to comment.