--- import BaseLayout from "@/layouts/BaseLayout.astro"; import { getDatabase, schema } from "@/db"; import { eq, desc, and, like } from "drizzle-orm"; import { BookMarked, Star, GitFork, Plus, Search, Lock, Globe, GitBranch } from "lucide-react"; const user = Astro.locals.user; if (!user) { return Astro.redirect("/login"); } const db = getDatabase(); const q = Astro.url.searchParams.get("q") || ""; const typeFilter = Astro.url.searchParams.get("type") || "all"; // Fetch user's repositories with search const allUserRepos = await db.query.repositories.findMany({ where: eq(schema.repositories.ownerId, user.id), orderBy: [desc(schema.repositories.updatedAt)], }); const repos = allUserRepos.filter((r) => { const matchesQ = !q || r.name.toLowerCase().includes(q.toLowerCase()) || (r.description && r.description.toLowerCase().includes(q.toLowerCase())); const matchesType = typeFilter === "all" || (typeFilter === "public" && r.visibility === "public") || (typeFilter === "private" && r.visibility === "private"); return matchesQ && matchesType; }); const publicCount = allUserRepos.filter(r => r.visibility === "public").length; const privateCount = allUserRepos.filter(r => r.visibility === "private").length; const langColors: Record = { JavaScript: "bg-[#f1e05a]", TypeScript: "bg-[#3178c6]", Python: "bg-[#3572A5]", Rust: "bg-[#dea584]", Go: "bg-[#00ADD8]", Java: "bg-[#b07219]", Ruby: "bg-[#701516]", "C++": "bg-[#f34b7d]", C: "bg-[#555555]", PHP: "bg-[#4F5D95]", HTML: "bg-[#e34c26]", CSS: "bg-[#563d7c]", Vue: "bg-[#41b883]", Astro: "bg-[#ff5a03]", Shell: "bg-[#89e051]", Dockerfile: "bg-[#384d54]", }; function timeAgo(date: Date) { const seconds = Math.floor( (new Date().getTime() - new Date(date).getTime()) / 1000, ); if (seconds < 60) return "just now"; if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`; if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`; if (seconds < 604800) return `${Math.floor(seconds / 86400)}d ago`; return `${Math.floor(seconds / 2592000)}mo ago`; } ---

Your Repositories {allUserRepos.length}

Manage and browse your personal codebase

New repository
{repos.length > 0 ? (
{repos.map((repo) => (
{repo.name} {repo.visibility === "public" ? "Public" : "Private"}
{repo.description && (

{repo.description}

)}
{repo.language && (
{repo.language}
)}
{repo.starCount || 0}
{repo.forkCount || 0}
· Updated {timeAgo(new Date(repo.updatedAt))}
))}
) : (

No repositories found

{q ? "No repositories match your search criteria." : "You haven't created any repositories yet."}

{!q && ( Create your first repository )}
)}