chore: Update dependencies and add sync-fetch for theme API

This commit is contained in:
Mauro Balades
2024-08-16 10:29:22 +02:00
parent b16302ba24
commit 58857925d0
3 changed files with 24 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
import fetch from "sync-fetch";
export interface ZenTheme {
name: string
@@ -8,17 +9,18 @@ export interface ZenTheme {
homepage?: string
}
const THEME_API = "https://zen-browser.github.io/theme-store/themes.json";
export function getAllThemes(): ZenTheme[] {
// TODO: Fetch themes from the marketplace (database or JSON file)
return [
{
name: "Zen",
description: "The default theme for Zen Browser",
downloadUrl: "https://zen-browser.app/download", // idrc
id: "zen",
image: "https://imgs.search.brave.com/qcDBMGuBLvJGLxWR3IkZyg35vROTSZ2omLn_0iLU2rs/rs:fit:860:0:0:0/g:ce/aHR0cHM6Ly9pLnBp/bmltZy5jb20vb3Jp/Z2luYWxzLzgxL2Mz/LzE0LzgxYzMxNDI5/MmViOGM3YzYxNmY5/ZjM3YTRmZDI5ODU4/LmpwZw",
},
];
// Fetch from the API
const response = fetch(THEME_API, {});
const themes = response.json();
// transform in to a ZenTheme[] as it is currently an object
let themesArray: ZenTheme[] = [];
for (let key in themes) {
themesArray.push(themes[key]);
}
return themesArray;
}
export function getThemesFromSearch(themes: ZenTheme[], query: string): ZenTheme[] {