From 9114a3ea7a4f93fd5b85972c5b3fe68b6814d063 Mon Sep 17 00:00:00 2001 From: Rayan Date: Mon, 23 Mar 2026 09:24:40 +0000 Subject: [PATCH 1/7] feat: add multi-language README support --- src/app/api/generate/route.ts | 4 +- src/app/generate/GeneratePageClient.tsx | 4 +- src/components/Generator/SearchInput.tsx | 72 +++++++++++++++++------- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/src/app/api/generate/route.ts b/src/app/api/generate/route.ts index 3c7f56f..fd8ddb9 100644 --- a/src/app/api/generate/route.ts +++ b/src/app/api/generate/route.ts @@ -10,9 +10,11 @@ export const dynamic = "force-dynamic"; */ export async function POST(req: Request) { let rawUrl: string; + let language: string; try { const body = await req.json(); rawUrl = body.url; + language = body.language || "English"; } catch { return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 }); } @@ -96,7 +98,7 @@ export async function POST(req: Request) { // Fix: Prompt updated with neutral fallbacks and dynamic license const prompt = ` **Role**: You are a Principal Solutions Architect and World-Class Technical Writer. -**Task**: Generate a professional, high-conversion README.md for the GitHub repository: "${repo}". +**Task**: Generate a professional, high-conversion README.md for the GitHub repository: "${repo}" in the following language: **${language}**. --- ### 1. PROJECT CONTEXT (VERIFIED DATA) diff --git a/src/app/generate/GeneratePageClient.tsx b/src/app/generate/GeneratePageClient.tsx index 8980251..039e46a 100644 --- a/src/app/generate/GeneratePageClient.tsx +++ b/src/app/generate/GeneratePageClient.tsx @@ -26,14 +26,14 @@ export default function GeneratePageClient({ repoSlug }: GeneratePageProps) { } }, [repoSlug]); - const handleGenerate = async (githubUrl: string) => { + const handleGenerate = async (githubUrl: string, language: string = "English") => { setIsLoading(true); setMarkdown(""); try { const response = await fetch("/api/generate", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ url: githubUrl }), + body: JSON.stringify({ url: githubUrl, language }), }); if (!response.ok) { diff --git a/src/components/Generator/SearchInput.tsx b/src/components/Generator/SearchInput.tsx index 1f6d1fe..98f0810 100644 --- a/src/components/Generator/SearchInput.tsx +++ b/src/components/Generator/SearchInput.tsx @@ -4,7 +4,7 @@ import { Loader2, Github, AlertCircle } from "lucide-react"; import { Button } from "../ui/Button"; interface SearchInputProps { - onGenerate: (url: string) => void; + onGenerate: (url: string, language: string) => void; isLoading: boolean; initialValue?: string; // optional initial value ariaLabel?: string; // optional aria-label for accessibility @@ -18,8 +18,23 @@ export const SearchInput = ({ }: SearchInputProps) => { // Initialize state directly from initialValue once const [url, setUrl] = useState(initialValue || ""); + const [language, setLanguage] = useState("English"); const [error, setError] = useState(null); + const languages = [ + "English", + "Spanish", + "French", + "German", + "Chinese", + "Japanese", + "Korean", + "Portuguese", + "Russian", + "Arabic", + "Turkish", + ]; + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); setError(null); @@ -28,36 +43,51 @@ export const SearchInput = ({ /^https?:\/\/(www\.)?github\.com\/[\w.-]+\/[\w.-]+\/?$/; if (githubUrlPattern.test(url.trim())) { - onGenerate(url.trim()); + onGenerate(url.trim(), language); } else { setError("Please enter a valid GitHub repository URL."); } }; return ( -
-
-
- +
+ +
+
+ +
+ { + setUrl(e.target.value); + if (error) setError(null); + }} + placeholder="https://github.com/username/repo" + aria-label={ariaLabel} + className={`w-full bg-zinc-900/50 border ${ + error ? "border-red-500/50" : "border-white/10" + } rounded-2xl py-6 pl-14 pr-4 text-white placeholder:text-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all backdrop-blur-xl`} + />
- { - setUrl(e.target.value); - if (error) setError(null); - }} - placeholder="https://github.com/username/repo" - aria-label={ariaLabel} - className={`w-full bg-zinc-900/50 border ${ - error ? "border-red-500/50" : "border-white/10" - } rounded-2xl py-6 pl-14 pr-40 text-white placeholder:text-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all backdrop-blur-xl`} - /> -
+ +
+ +