chore: Update ThemePage component to display theme readme

This commit is contained in:
Mauro Balades
2024-08-16 10:46:46 +02:00
parent b944861344
commit 73cd1c22ee
2 changed files with 37 additions and 5 deletions

View File

@@ -7,13 +7,19 @@ export interface ZenTheme {
downloadUrl: string
id: string
homepage?: string
readme: string
preferences: {
[key: string]: string
},
author: string
}
const THEME_API = "https://zen-browser.github.io/theme-store/themes.json";
const CACHE_OPTIONS = {};
export function getAllThemes(): ZenTheme[] {
// Fetch from the API
const response = fetch(THEME_API, {});
const response = fetch(THEME_API, CACHE_OPTIONS);
const themes = response.json();
// transform in to a ZenTheme[] as it is currently an object
let themesArray: ZenTheme[] = [];
@@ -30,3 +36,7 @@ export function getThemesFromSearch(themes: ZenTheme[], query: string): ZenTheme
export function getThemeFromId(id: string): ZenTheme | undefined {
return getAllThemes().find((theme) => theme.id === id);
}
export function getThemeMarkdown(theme: ZenTheme): string {
return fetch(theme.readme, CACHE_OPTIONS).text();
}