Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added release page in docs #6669

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/pages/releases.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Releases
---

import {Releases} from '@site/src/components/Releases';

<Releases repository="chainsafe/lodestar" />
1 change: 1 addition & 0 deletions docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {SidebarsConfig} from "@docusaurus/plugin-content-docs";
const sidebars: SidebarsConfig = {
tutorialSidebar: [
"index",
"releases",
"introduction",
{
type: "category",
Expand Down
60 changes: 60 additions & 0 deletions docs/src/components/Releases/index.tsx
Original file line number Diff line number Diff line change
@@ -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://github.com/gitapi/repos/${repository}/releases`)
.then((response) => response.json())
.then(setReleases)
.catch(() => setReleases([]));
});

if (releases.length === 0) {
return <div>No releases</div>;
} else {
return (
<table>
<thead>
<tr>
<th>Version</th>
<th>Release Date</th>
<th>Downloads</th>
</tr>
</thead>
<tbody>
{releases &&
releases.map((release) => (
<tr key={release.id}>
<td>{release.name}</td>
<td>{release.published_at}</td>
<td>
{release.assets.map((asset) => (
<a key={asset.id} href={asset.browser_download_url}>
<div>{asset.name}</div>
</a>
))}
</td>
</tr>
))}
</tbody>
</table>
);
}
}
Loading