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.

) } const plugin = (registryData as Record)[slug] const starsBadgeUrl = getGitHubStarsBadgeUrl(plugin?.repo) if (!plugin) { return (

Plugin {slug} not found.

) } return (
{plugin.imageUrl && ( {`${plugin.name} )}

{plugin.name}

{plugin.featured && ( Featured )}

{plugin.description}

{plugin.version && (
Version: v{plugin.version}
)} {plugin.author && (
Author: {plugin.author}
)}
{(pluginStats?.flashCount ?? 0).toLocaleString()}
{starsBadgeUrl && plugin.repo && ( GitHub stars )}
{plugin.repo && ( )} {plugin.homepage && plugin.homepage !== plugin.repo && ( )}
{plugin.dependencies && Object.keys(plugin.dependencies).length > 0 && (

Dependencies

{Object.entries(plugin.dependencies).map(([depName, depVersion]) => (
{depName}: {depVersion}
))}
)} {plugin.includes && plugin.includes.length > 0 && (

Supported Platforms

{plugin.includes.map(platform => ( {platform} ))}
)}
) }