Skip to content

Commit

Permalink
Update fetch.ts
Browse files Browse the repository at this point in the history
- add getDownloads function
  • Loading branch information
sudo-adduser-jordan committed Feb 13, 2025
1 parent 9e4189c commit 63d3f4b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/scripts/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ import type { Icon } from "../scripts/types.ts";
import type { Config } from "../scripts/types.ts";
import type { List } from "../scripts/types.ts";

export async function getDownloads(maintainer: string, repository: string): Promise<string> {
const response = await fetch(`https://api.github.com/repos/${maintainer}/${repository}/releases`);
const data = await response.json();
return data[0]["assets"][0]["download_count"];
}

export async function fetchThemes(storeResults: HTMLElement | null): Promise<HTMLElement | null> {
const response = await fetch("https://raw.githubusercontent.com/linux-themes/database/refs/heads/main/themes/index.yml");
const data = await response.text();
const packages: List = jsyaml.load(data) as List;
if (typeof packages === "object" && storeResults) {
if (storeResults) {
for (const index in packages["themes"]) {
storeResults.innerHTML += generateCardHTML(packages["themes"][index], index);
}
Expand All @@ -20,7 +26,7 @@ export async function fetchIcons(storeResults: HTMLElement | null): Promise<HTML
const response = await fetch("https://raw.githubusercontent.com/linux-themes/database/refs/heads/main/icons/index.yml");
const data = await response.text();
const packages: List = jsyaml.load(data) as List;
if (typeof packages === "object" && storeResults) {
if (storeResults) {
for (const index in packages["icons"]) {
storeResults.innerHTML += generateCardHTML(packages["icons"][index], index);
}
Expand All @@ -32,7 +38,7 @@ export async function fetchConfigs(storeResults: HTMLElement | null): Promise<HT
const response = await fetch("https://raw.githubusercontent.com/linux-themes/database/refs/heads/main/configs/index.yml");
const data = await response.text();
const packages: List = jsyaml.load(data) as List;
if (typeof packages === "object" && storeResults) {
if (storeResults) {
for (const index in packages["configs"]) {
storeResults.innerHTML += generateCardHTML(packages["configs"][index], index);
}
Expand Down

0 comments on commit 63d3f4b

Please sign in to comment.