diff --git a/src/components/theme-page.tsx b/src/components/theme-page.tsx index 6ff9a61..de3b801 100644 --- a/src/components/theme-page.tsx +++ b/src/components/theme-page.tsx @@ -1,11 +1,20 @@ -import { ZenTheme } from "@/lib/themes"; +import { getThemeMarkdown, ZenTheme } from "@/lib/themes"; import { Button } from "./ui/button"; +import { useEffect, useState } from "react"; +import Markdown from "react-markdown"; +import '../app/privacy-policy/markdown.css'; export default function ThemePage({ theme }: { theme: ZenTheme }) { + const [readme, setReadme] = useState(null); + useEffect(() => { + setReadme(getThemeMarkdown(theme)); + }, []); + return (
-
-

{theme.name}

+
+ {theme.name} +

{theme.name}

{theme.description}

{theme.homepage && ( -

You need to have Zen Browser installed to install this theme. Download now!

+

You need to have Zen Browser installed to install this theme. Download now!

+
+
+
+ {`${readme}`} +
+
+

+ Theme by{" "} + + {theme.author} + +

); diff --git a/src/lib/themes.ts b/src/lib/themes.ts index 0fdbd2e..1a95e65 100644 --- a/src/lib/themes.ts +++ b/src/lib/themes.ts @@ -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(); +}