import { Button } from "@/components/ui/button" import { api } from "@/convex/_generated/api" import registryData from "@/public/registry.json" import { PluginDisplay } from "@/types" import { useQuery } from "convex/react" import { Download, Github, Home, Star } from "lucide-react" import { usePageContext } from "vike-react/usePageContext" import { navigate } from "vike/client/router" function getGitHubStarsBadgeUrl(repoUrl?: string): string | null { if (!repoUrl) return null try { const url = new URL(repoUrl) if (url.hostname === "github.com" || url.hostname === "www.github.com") { const pathParts = url.pathname.split("/").filter(Boolean) if (pathParts.length >= 2) { const owner = pathParts[0] const repo = pathParts[1] return `https://img.shields.io/github/stars/${owner}/${repo}?style=flat&logo=github&logoColor=white&labelColor=rgb(0,0,0,0)&color=rgb(30,30,30)&label=★` } } } catch { // Invalid URL } return null } export default function PluginPage() { const pageContext = usePageContext() const slug = pageContext.routeParams?.slug as string | undefined const pluginStats = useQuery(api.plugins.get, slug ? { slug } : "skip") if (!slug) { return (
Plugin slug missing.
Plugin {slug} not found.