diff --git a/README.md b/README.md index 6cf4bd1..7cf68c9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ ReadmeGenAI eliminates this friction by leveraging advanced AI to automatically Main Page

- Feature Page + Feature Page

## Technical Architecture diff --git a/assets/fearture-page.png b/assets/feature-page.png similarity index 100% rename from assets/fearture-page.png rename to assets/feature-page.png diff --git a/src/app/api/generate/route.ts b/src/app/api/generate/route.ts index 8eaaeee..2f6b26d 100644 --- a/src/app/api/generate/route.ts +++ b/src/app/api/generate/route.ts @@ -9,7 +9,7 @@ export const dynamic = "force-dynamic"; * AI README Generation Endpoint * Optimized for data accuracy, clean prompt interpolation, and multi-language support. * - * @param {Request} req - The incoming request object containing the repo URL and optional language. + * @param {Request} req - The incoming Fastify request object containing the repo URL and optional language. * @returns {Promise} A JSON response containing the generated Markdown or an error message. */ export async function POST(req: Request) { @@ -18,13 +18,7 @@ export async function POST(req: Request) { try { const body = await req.json(); rawUrl = body.url; - const rawLanguage = - typeof body.language === "string" ? body.language.trim() : ""; - const normalized = - rawLanguage.charAt(0).toUpperCase() + rawLanguage.slice(1).toLowerCase(); - language = (SUPPORTED_LANGUAGES as readonly string[]).includes(normalized) - ? normalized - : "English"; + language = body.language || "English"; } catch { return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 }); } @@ -157,9 +151,12 @@ export async function POST(req: Request) { const result = await model.generateContent(prompt); const response = await result.response; - const markdown = response.text(); + const markdown = response.text().trim(); + const cleanMarkdown = markdown + .replace(/^```(markdown|md)?\n/, "") + .replace(/\n```$/, ""); - return NextResponse.json({ markdown }); + return NextResponse.json({ markdown: cleanMarkdown }); } catch (error: unknown) { const message = error instanceof Error ? error.message : "Internal Server Error"; diff --git a/src/components/Generator/SearchInput.tsx b/src/components/Generator/SearchInput.tsx index eee2617..dc3829b 100644 --- a/src/components/Generator/SearchInput.tsx +++ b/src/components/Generator/SearchInput.tsx @@ -29,6 +29,20 @@ export const SearchInput = ({ 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); @@ -72,10 +86,9 @@ export const SearchInput = ({