Skip to content

Commit 44651a1

Browse files
authored
fetch banner info from github (#1094)
1 parent 04bab85 commit 44651a1

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

docs/vercel/src/Index.svelte

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import AsciiPreview from './lib/AsciiPreview.svelte';
33
import data from '../../../languages.yaml';
44
import type { Languages } from '../../../languages.yaml';
5+
import { onMount } from 'svelte';
6+
7+
let tag_name: string;
8+
let html_url: string;
59
610
const languages = Object.entries(data as Languages).map(
711
([name, { ascii, colors }]) => ({
@@ -10,16 +14,30 @@
1014
...colors,
1115
})
1216
);
17+
18+
onMount(async () => {
19+
try {
20+
const response = await fetch(
21+
'https://api.github.com/repos/o2sh/onefetch/releases/latest'
22+
);
23+
const data = await response.json();
24+
25+
tag_name = data.tag_name;
26+
html_url = data.html_url;
27+
} catch (error) {
28+
console.error('Error:', error);
29+
}
30+
});
1331
</script>
1432

1533
<header>
16-
<div class="banner">
17-
<small
18-
>Version 2.18 is available 🎉 Check the <a
19-
href="https://github.com/o2sh/onefetch/releases/tag/2.18.0"
20-
>release notes</a
21-
>!!</small>
22-
</div>
34+
{#if tag_name && html_url}
35+
<div class="banner">
36+
<small
37+
>Version {tag_name} is available 🎉 Check the
38+
<a href={html_url}>release notes</a>!!</small>
39+
</div>
40+
{/if}
2341
<h1>Onefetch</h1>
2442
<p>
2543
<small>

0 commit comments

Comments
 (0)