diff --git a/apps/web/src/app/docs/layout.tsx b/apps/web/src/app/docs/layout.tsx index 63b2501..5020e9a 100644 --- a/apps/web/src/app/docs/layout.tsx +++ b/apps/web/src/app/docs/layout.tsx @@ -1,13 +1,17 @@ import { Banner } from "fumadocs-ui/components/banner"; import { DocsLayout, type DocsLayoutProps } from "fumadocs-ui/layouts/docs"; import type { ReactNode } from "react"; -import { baseOptions, links } from "@/app/layout.config"; +import { baseOptions } from "@/app/layout.config"; +import { SpecialSponsorBanner } from "@/components/special-sponsor-banner"; import { source } from "@/lib/source"; const docsOptions: DocsLayoutProps = { ...baseOptions, tree: source.pageTree, - links: links.filter((link) => "text" in link && link.text !== "Docs"), + links: [], + sidebar: { + banner: , + }, }; export default function Layout({ children }: { children: ReactNode }) { diff --git a/apps/web/src/components/special-sponsor-banner.tsx b/apps/web/src/components/special-sponsor-banner.tsx new file mode 100644 index 0000000..c56bf27 --- /dev/null +++ b/apps/web/src/components/special-sponsor-banner.tsx @@ -0,0 +1,75 @@ +"use client"; +import Image from "next/image"; +import { useEffect, useState } from "react"; +import type { Sponsor } from "@/lib/types"; + +const isSpecialSponsor = (sponsor: Sponsor) => { + return sponsor.monthlyDollars >= 100; +}; + +export function SpecialSponsorBanner() { + const [specialSponsor, setSpecialSponsor] = useState(null); + const [loading, setLoading] = useState(true); + + useEffect(() => { + fetch("https://sponsors.amanv.dev/sponsors.json") + .then((res) => { + if (!res.ok) throw new Error("Failed to fetch sponsors"); + return res.json(); + }) + .then((data) => { + const sponsorsData = Array.isArray(data) ? data : []; + const specialSponsor = sponsorsData.find( + (sponsor) => sponsor.monthlyDollars > 0 && isSpecialSponsor(sponsor), + ); + + if (specialSponsor) { + setSpecialSponsor(specialSponsor); + } + setLoading(false); + }) + .catch(() => { + setLoading(false); + }); + }, []); + + if (loading) { + return ( +
+
+
+
+
+
+
+
+ ); + } + + if (!specialSponsor) { + return null; + } + + return ( +
+
+ {specialSponsor.sponsor.name +
+

+ {specialSponsor.sponsor.name || specialSponsor.sponsor.login} +

+
+
+
+ ); +}