diff --git a/docs/pages/releases.mdx b/docs/pages/releases.mdx new file mode 100644 index 000000000000..8e4f36c5f621 --- /dev/null +++ b/docs/pages/releases.mdx @@ -0,0 +1,7 @@ +--- +title: Releases +--- + +import {Releases} from '@site/src/components/Releases'; + + \ No newline at end of file diff --git a/docs/sidebars.ts b/docs/sidebars.ts index c64e39b8b5f2..5e4f70c414aa 100644 --- a/docs/sidebars.ts +++ b/docs/sidebars.ts @@ -3,6 +3,7 @@ import type {SidebarsConfig} from "@docusaurus/plugin-content-docs"; const sidebars: SidebarsConfig = { tutorialSidebar: [ "index", + "releases", "introduction", { type: "category", diff --git a/docs/src/components/Releases/index.tsx b/docs/src/components/Releases/index.tsx new file mode 100644 index 000000000000..7fc8e1caca71 --- /dev/null +++ b/docs/src/components/Releases/index.tsx @@ -0,0 +1,60 @@ +import React, {useEffect, useState} from "react"; + +export type Asset = { + // eslint-disable-next-line prettier/prettier, @typescript-eslint/naming-convention + browser_download_url: string; + id: number; + name: string; +}; + +export type Release = { + id: number; + name: string; + // eslint-disable-next-line prettier/prettier, @typescript-eslint/naming-convention + published_at: string; + assets: Asset[]; +}; + +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/naming-convention +export function Releases({repository}: {repository: string}) { + const [releases, setReleases] = useState([]); + + useEffect(() => { + fetch(`https://api.github.com/repos/${repository}/releases`) + .then((response) => response.json()) + .then(setReleases) + .catch(() => setReleases([])); + }); + + if (releases.length === 0) { + return
No releases
; + } else { + return ( + + + + + + + + + + {releases && + releases.map((release) => ( + + + + + + ))} + +
VersionRelease DateDownloads
{release.name}{release.published_at} + {release.assets.map((asset) => ( + +
{asset.name}
+
+ ))} +
+ ); + } +}