Skip to content

Commit

Permalink
fetch latest version dmg url at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
ritz078 committed Apr 28, 2020
1 parent 117d1de commit d6ff192
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "moose-www",
"version": "0.4.0",
"main": "index.js",
"author": "Ritesh Kumar",
"license": "MIT",
Expand Down
21 changes: 16 additions & 5 deletions website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { mdiApple, mdiGithub, mdiLinux, mdiMicrosoftWindows } from "@mdi/js";
import Head from "next/head";
import ProgressiveImage from "react-progressive-image";
import { version } from "../../package.json";
import axios from "axios";

const Particles = dynamic(() => import("react-particles-js"), {
ssr: false,
Expand All @@ -27,7 +28,20 @@ const params: IParticlesParams = {
},
};

export default () => {
export async function getStaticProps() {
const { data } = await axios.get(
"https://api.github.com/repos/ritz078/moose/releases/latest"
);
return {
props: {
macUrl: data.assets.find(
(assets) => assets.content_type === "application/octet-stream"
).browser_download_url,
},
};
}

export default ({ macUrl }) => {
return (
<div className="wrapper">
<Head>
Expand Down Expand Up @@ -58,10 +72,7 @@ export default () => {
<span>A torrent client to download, stream and cast torrents.</span>

<div className="downloads">
<a
href={`https://github.com/ritz078/moose/releases/download/v${version}/moose-${version}.dmg`}
target="_blank"
>
<a href={macUrl} target="_blank">
<button className="download-button">
<Icon path={mdiApple} size={1.2} />
</button>
Expand Down

0 comments on commit d6ff192

Please sign in to comment.