-
Notifications
You must be signed in to change notification settings - Fork 6
add SEO #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
add SEO #29
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
95fd01f
add SEO
naheel0 36e9c38
[autofix.ci] apply automated fixes
autofix-ci[bot] 53b0c12
Initial plan
Copilot 07eb163
Fix Next.js 15+ compatibility and SEO metadata URLs
Copilot 3b50fb7
Merge pull request #30 from BeyteFlow/copilot/sub-pr-29
naheel0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| "use client"; | ||
| import React, { useState, useEffect } from "react"; | ||
| import { Navbar } from "@/components/layout/Navbar"; | ||
| import { Footer } from "@/components/layout/Footer"; | ||
| import { SearchInput } from "@/components/Generator/SearchInput"; | ||
| import { MarkdownPreview } from "@/components/Generator/MarkdownPreview"; | ||
| import { navLinks } from "@/constants/navLinks"; | ||
|
|
||
| interface GeneratePageProps { | ||
| repoSlug?: string; // Optional pre-filled repo from server-side route | ||
| } | ||
|
|
||
| export default function GeneratePageClient({ repoSlug }: GeneratePageProps) { | ||
| const [markdown, setMarkdown] = useState(""); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
|
|
||
| // Optional: Update document title for SPA navigation | ||
| useEffect(() => { | ||
| if (repoSlug) { | ||
| const repoName = repoSlug.split("/").pop(); | ||
| document.title = `Generate README for ${repoName} | ReadmeGenAI`; | ||
| } else { | ||
| document.title = "ReadmeGenAI – AI GitHub README Generator"; | ||
| } | ||
| }, [repoSlug]); | ||
|
|
||
| const handleGenerate = async (githubUrl: string) => { | ||
| setIsLoading(true); | ||
| setMarkdown(""); | ||
| try { | ||
| const response = await fetch("/api/generate", { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify({ url: githubUrl }), | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| const errorText = await response.text(); | ||
| let errorMessage: string; | ||
| try { | ||
| const errorData = JSON.parse(errorText); | ||
| errorMessage = errorData.error || errorData.message || errorText; | ||
| } catch { | ||
| errorMessage = errorText || response.statusText; | ||
| } | ||
| throw new Error( | ||
| `[${response.status} ${response.statusText}]: ${errorMessage}`, | ||
| ); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| if (data && typeof data.markdown === "string") { | ||
| setMarkdown(data.markdown); | ||
| } else { | ||
| setMarkdown(""); | ||
| throw new Error( | ||
| "Invalid response: markdown content is missing or invalid", | ||
| ); | ||
| } | ||
| } catch (error: unknown) { | ||
| console.error("Generation Error:", error); | ||
| alert(error instanceof Error ? error.message : "Something went wrong"); | ||
| } finally { | ||
| setIsLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="min-h-screen bg-black text-white"> | ||
| <Navbar links={navLinks} /> | ||
| <main className="pt-40 pb-20 px-4 max-w-6xl mx-auto"> | ||
| <SearchInput | ||
| onGenerate={handleGenerate} | ||
| isLoading={isLoading} | ||
| initialValue={repoSlug ? `https://github.com/${repoSlug}` : ""} | ||
| aria-label="Enter GitHub repository URL to generate README" | ||
| /> | ||
| <MarkdownPreview content={markdown} /> | ||
| </main> | ||
| <Footer /> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import type { Metadata } from "next"; | ||
| import GeneratePageClient from "@/app/generate/GeneratePageClient"; | ||
|
|
||
| interface PageProps { | ||
| params: Promise<{ | ||
| repo: string; // e.g., "facebook/react" | ||
| }>; | ||
| } | ||
|
|
||
| // Dynamic Metadata for SEO and social sharing | ||
| export async function generateMetadata({ | ||
| params, | ||
| }: PageProps): Promise<Metadata> { | ||
| const resolvedParams = await params; | ||
| const repoName = resolvedParams.repo; // full repo slug like "facebook/react" | ||
| const repoDisplayName = repoName.split("/").pop(); // e.g., "react" | ||
|
|
||
| return { | ||
| title: `AI-Generated README for ${repoDisplayName} | ReadmeGenAI`, | ||
| description: `Use ReadmeGenAI to automatically generate a professional README.md for the ${repoName} repository. Paste your repo URL and get documentation instantly.`, | ||
| openGraph: { | ||
| title: `README for ${repoDisplayName} | ReadmeGenAI`, | ||
| description: `Generate a polished README.md for ${repoName} using ReadmeGenAI.`, | ||
| url: `/generate/${repoName}`, | ||
| siteName: "ReadmeGenAI", | ||
| images: [ | ||
| { | ||
| url: "/og-image.png", | ||
| width: 1200, | ||
| height: 630, | ||
| alt: `ReadmeGenAI - AI README Generator for ${repoDisplayName}`, | ||
| }, | ||
| ], | ||
| type: "website", | ||
| }, | ||
| twitter: { | ||
| card: "summary_large_image", | ||
| title: `AI-Generated README for ${repoDisplayName}`, | ||
| description: `Generate a professional README for ${repoName} using ReadmeGenAI in seconds.`, | ||
| images: ["/og-image.png"], | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| // Server-side wrapper for your client component | ||
| export default async function GeneratePageServer({ params }: PageProps) { | ||
| // Pass the repoSlug to the client component so it can pre-fill input & update title | ||
| const resolvedParams = await params; | ||
| return <GeneratePageClient repoSlug={resolvedParams.repo} />; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.