diff --git a/next.config.mjs b/next.config.mjs index d7c67b0..7d5f96b 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -12,6 +12,7 @@ const nextConfig = { hostname: "cdn.jsdelivr.net", } ], + domains: ['cdn.jsdelivr.net', "raw.githubusercontent.com"], // Allow images from jsDelivr }, experimental: { serverActions: { @@ -22,19 +23,6 @@ const nextConfig = { compiler: { styledComponents: true, }, - async headers() { - return [ - { - source: "/", - headers: [ - { - key: "Cache-Control", - value: "s-maxage=1, stale-while-revalidate=59", - }, - ], - }, - ] - } }; export default nextConfig; diff --git a/src/app/favicon.ico b/public/favicon.ico similarity index 100% rename from src/app/favicon.ico rename to public/favicon.ico diff --git a/src/app/api/get-theme/[id]/route.ts b/src/app/api/get-theme/[id]/route.ts new file mode 100644 index 0000000..78c7a69 --- /dev/null +++ b/src/app/api/get-theme/[id]/route.ts @@ -0,0 +1,25 @@ +import { getAllThemes, getThemeFromId } from '@/lib/themes'; +import type { NextApiRequest, NextApiResponse } from 'next'; +import { NextRequest, NextResponse } from 'next/server'; + +// Static NextJS API route. We will have /get-theme?id=theme-id static route +export async function generateStaticParams() { + const themes = await getAllThemes(); + return themes.map((theme) => ({ + id: theme.id, + })); +} + + +function removeUneccessaryKeys(theme: any) { + delete theme["isDarkMode"]; + delete theme["isColorTheme"]; + return theme; +} + +export async function GET(request: any, { params }: { params: { id: string } }) { + const themes = await getAllThemes(); + const theme = themes.find((theme) => theme.id === params.id); + console.log(theme); + return NextResponse.json(removeUneccessaryKeys(theme)); +} \ No newline at end of file diff --git a/src/app/api/get-theme/route.ts b/src/app/api/get-theme/route.ts deleted file mode 100644 index 900730d..0000000 --- a/src/app/api/get-theme/route.ts +++ /dev/null @@ -1,30 +0,0 @@ - -import { getThemeFromId } from "@/lib/themes"; - -function getQSParamFromURL( - key: string, - url: string | undefined -): string | null { - if (!url) return ""; - const search = new URL(url).search; - const urlParams = new URLSearchParams(search); - return urlParams.get(key); -} - -function removeUneccessaryKeys(theme: any) { - delete theme["isDarkMode"]; - delete theme["isColorTheme"]; - return theme; -} - -export async function GET(request: Request, response: Response) { - const id = getQSParamFromURL("id", request.url); - if (!id) { - return Response.json({ error: "id is required" }); - } - const theme = await getThemeFromId(id); - if (!theme) { - return Response.json({ error: "theme not found" }); - } - return Response.json(removeUneccessaryKeys(theme)); -} \ No newline at end of file diff --git a/src/app/privacy-policy/page.tsx b/src/app/privacy-policy/page.tsx index 5408dea..32236a3 100644 --- a/src/app/privacy-policy/page.tsx +++ b/src/app/privacy-policy/page.tsx @@ -1,3 +1,4 @@ +"use client"; import Footer from "@/components/footer"; import { Navigation } from "@/components/navigation"; import { releaseNoteIsAlpha, releaseNotes } from "@/lib/release-notes"; diff --git a/src/app/release-notes/[version]/page.tsx b/src/app/release-notes/[version]/page.tsx index 8992c4f..69d7cbc 100644 --- a/src/app/release-notes/[version]/page.tsx +++ b/src/app/release-notes/[version]/page.tsx @@ -1,4 +1,3 @@ -"use client"; import Footer from "@/components/footer"; import { Navigation } from "@/components/navigation"; @@ -6,10 +5,13 @@ import ReleaseNote from "@/components/release-note"; import { Button } from "@/components/ui/button"; import { releaseNotes } from "@/lib/release-notes"; import Link from "next/link"; -import { redirect, useParams } from "next/navigation"; +import { redirect } from "next/navigation"; -export default function ReleaseNotePage() { - const params = useParams<{ version: string }>(); +export async function generateStaticParams() { + return [{version: "latest"}, ...releaseNotes.map((note) => ({ version: note.version }))]; +} + +export default function ReleaseNotePage({ params }: { params: { version: string } }) { const { version } = params; if (version === "latest") { diff --git a/src/app/release-notes/page.tsx b/src/app/release-notes/page.tsx index 8650f56..07f304c 100644 --- a/src/app/release-notes/page.tsx +++ b/src/app/release-notes/page.tsx @@ -1,3 +1,5 @@ +"use client"; + import Footer from "@/components/footer"; import { Navigation } from "@/components/navigation"; import { releaseNoteIsAlpha, releaseNotes } from "@/lib/release-notes"; diff --git a/src/app/themes/[theme]/page.tsx b/src/app/themes/[theme]/page.tsx index ab32280..e957cc0 100644 --- a/src/app/themes/[theme]/page.tsx +++ b/src/app/themes/[theme]/page.tsx @@ -2,7 +2,7 @@ import Footer from "@/components/footer"; import { Navigation } from "@/components/navigation"; import ThemePage from "@/components/theme-page"; -import { getThemeFromId } from "@/lib/themes"; +import { getAllThemes, getThemeFromId } from "@/lib/themes"; import { Metadata, ResolvingMetadata } from "next"; export async function generateMetadata( @@ -36,10 +36,19 @@ export async function generateMetadata( }; } -export default async function ThemeInfoPage() { +export async function generateStaticParams() { + const themes = await getAllThemes(); + console.log(themes); + return themes.map((theme) => ({ + theme: theme.id, + })); +} + +export default async function ThemeInfoPage({ params }: { params: { theme: string } }) { + const { theme } = params; return (
- +
diff --git a/src/components/download.tsx b/src/components/download.tsx index f5f7e79..968147d 100644 --- a/src/components/download.tsx +++ b/src/components/download.tsx @@ -1,5 +1,4 @@ "use client"; -import { addDownload } from "@/lib/db"; import { useState, useEffect } from "react"; import styled, { keyframes } from "styled-components"; import { ny } from "@/lib/utils"; @@ -158,7 +157,6 @@ export default function DownloadPage() { window.location.replace(`${BASE_URL}/${releases[releaseTarget]}`); } setHasDownloaded(true); - addDownload(releaseTarget); throwConfetti(); }; diff --git a/src/components/features.tsx b/src/components/features.tsx index 8683e0f..30bbfc4 100644 --- a/src/components/features.tsx +++ b/src/components/features.tsx @@ -220,7 +220,7 @@ export default function Features() { How Zen compares to other browsers - - - - browser Image - - Zen Logo + Zen Logo {withText && zen} ); diff --git a/src/components/theme-card.tsx b/src/components/theme-card.tsx index 9e23b98..66ab418 100644 --- a/src/components/theme-card.tsx +++ b/src/components/theme-card.tsx @@ -20,7 +20,7 @@ export default function ThemeCard({ if (event.target instanceof HTMLAnchorElement) return; window.open(`/themes/${theme.id}`, "_self"); }} className="flex flex-col justify-start p-5 rounded-lg shadow-sm bg-muted dark:bg-muted/50 border border-grey-900 dark:border-muted w-full hover:shadow-lg transition duration-300 ease-in-out hover:bg-muted/100 hover:border-blue-500 cursor-pointer select-none "> - {theme.name}

{theme.name.substring(0, maxNameLen).trim() + (theme.name.length > maxNameLen ? "..." : "")}

diff --git a/src/components/theme-page.tsx b/src/components/theme-page.tsx index 59f2114..89de75f 100644 --- a/src/components/theme-page.tsx +++ b/src/components/theme-page.tsx @@ -1,4 +1,4 @@ -"use client"; + import Image from "next/image"; import { getThemeAuthorLink, getThemeFromId, getThemeMarkdown, ZenTheme } from "@/lib/themes"; import { Button } from "./ui/button"; @@ -6,11 +6,8 @@ import { useEffect, useState } from "react"; import Markdown from "react-markdown"; import '../app/privacy-policy/markdown.css'; import { ChevronLeft, LoaderCircleIcon } from "lucide-react"; -import { useParams } from "next/navigation"; -export default async function ThemePage() { - const params = useParams<{ theme: string }>(); - const { theme: themeID } = params; +export default async function ThemePage({ themeID }: { themeID: string }) { const theme = await getThemeFromId(themeID); if (!theme) { @@ -22,11 +19,11 @@ export default async function ThemePage() { return (
-
window.history.back()}> +

Go back

-
- {theme.name} + + {theme.name}

{theme.name}

{theme.description}

{theme.homepage && ( diff --git a/src/lib/db.ts b/src/lib/db.ts deleted file mode 100644 index 5551339..0000000 --- a/src/lib/db.ts +++ /dev/null @@ -1,31 +0,0 @@ -"use server"; - -import { createClient } from '@supabase/supabase-js' - -const supabaseUrl = 'https://dmthyedfjzcysoekmyns.supabase.co' -const supabaseKey = process.env.SUPABASE_KEY as string; -const supabase = createClient(supabaseUrl, supabaseKey); - -export async function addDownload(platform: string) { - // Check if the download count for the platform exists - const { data, error } = await supabase - .from('downloads') - .select('count') - .eq('platform', platform) - // If it doesn't exist, create it - console.log(data) - if (data?.length === 0 || data === null) { - const {data, error} = await supabase - .from('downloads') - .insert([{ platform, count: 1 }]); - if (error) { - console.error(error) - } - } else { - // If it exists, increment the count - await supabase - .from('downloads') - .update({ count: data![0].count + 1 }) - .eq('platform', platform) - } -} diff --git a/src/lib/release-notes.ts b/src/lib/release-notes.ts index 537fe57..3b2bbbb 100644 --- a/src/lib/release-notes.ts +++ b/src/lib/release-notes.ts @@ -628,11 +628,10 @@ export const releaseNotes: ReleaseNote[] = [ }, { version: "1.0.0-a.30", - date: "24/08/2024", + date: "26/08/2024", extra: "This release is the thirtieth alpha release of the 1.0.0-alpha series.", features: [ "Added support for 24 more languages!", - "Better wordmark and icons for Private Browsing mode", "Update installed themes from the browser settings" ], fixes: [ @@ -655,11 +654,38 @@ export const releaseNotes: ReleaseNote[] = [ { description: "Can't rename created workspace", issue: 604 + }, + { + description: "JavaScript won't execute in the browser console", + issue: 913 + } + ] + }, + { + version: "1.0.0-a.31", + date: "27/08/2024", + extra: "This release is the thirty-first alpha release of the 1.0.0-alpha series.", + features: [ + "Better wordmark and icons for Private Browsing mode", + "Patched security issue with remote debugging", + "Fixed incorrect position of right-side tabs in compact mode", + "Optimized image loading on website", + "Refactored website to be static" + ], + fixes: [ + { + description: "Horizontal and vertical split don't work with shortcuts", + issue: 915 + }, + { + description: "Buttons dissapear if there are too many tabs", + issue: 934 } ] } ].reverse(); export function releaseNoteIsAlpha(note: ReleaseNote) { + "use client"; return note.version.includes("-a."); } diff --git a/src/lib/themes.ts b/src/lib/themes.ts index 746b123..ebf6f5c 100644 --- a/src/lib/themes.ts +++ b/src/lib/themes.ts @@ -14,7 +14,9 @@ export interface ZenTheme { } const THEME_API = "https://zen-browser.github.io/theme-store/themes.json"; -const CACHE_OPTIONS = { cache: "no-cache" } as RequestInit; +const CACHE_OPTIONS = { next: { + revalidate: 60, +} } as RequestInit; export async function getAllThemes() { // Fetch from the API