Open History to see the last commit
1const REPO = "pingdotgg/t3code";
2
3export const RELEASES_URL = `https://github.com/${REPO}/releases`;
4
5const API_URL = `https://api.github.com/repos/${REPO}/releases/latest`;
6const CACHE_KEY = "t3code-latest-release";
7
8export interface ReleaseAsset {
9 name: string;
10 browser_download_url: string;
11}
12
13export interface Release {
14 tag_name: string;
15 html_url: string;
16 assets: ReleaseAsset[];
17}
18
19export async function fetchLatestRelease(): Promise<Release> {
20 const cached = sessionStorage.getItem(CACHE_KEY);
21 if (cached) return JSON.parse(cached);
22
23 const data = await fetch(API_URL).then((r) => r.json());
24
25 if (data?.assets) {
26 sessionStorage.setItem(CACHE_KEY, JSON.stringify(data));
27 }
28
29 return data;
30}