From 5206a5db50d5a8e253280205e6ff9d56bf6d09c4 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Jan 2026 22:29:09 +0000 Subject: [PATCH] Add sitemap, robots.txt, and improve homepage SEO - Add sitemap.ts with homepage entry - Add robots.ts to guide crawlers (disallow protected routes) - Move auth redirect to client-side to allow static rendering - Create AuthRedirect component that checks session via API --- app/page.tsx | 11 +++-------- app/robots.ts | 17 +++++++++++++++++ app/sitemap.ts | 15 +++++++++++++++ components/auth-redirect.tsx | 30 ++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 app/robots.ts create mode 100644 app/sitemap.ts create mode 100644 components/auth-redirect.tsx diff --git a/app/page.tsx b/app/page.tsx index 717b16c..a25c253 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,30 +1,25 @@ import type { Metadata } from "next"; -import { redirect } from "next/navigation"; +import { AuthRedirect } from "@/components/auth-redirect"; import { Footer } from "@/components/site/footer"; import { HomeHero } from "@/components/site/home-hero"; -import { getSession } from "@/lib/auth"; export const metadata: Metadata = { title: "Free Google sign-in for Ghost blogs", description: "Give Ghost members Google sign-in without magic links." }; -export default async function HomePage({ +export default function HomePage({ searchParams }: { searchParams?: { toast?: string | string[] }; }) { - const session = await getSession(); - if (session) { - redirect("/dashboard"); - } - const toast = typeof searchParams?.toast === "string" ? searchParams.toast : null; return (
+ { + const checkAuth = async () => { + try { + const response = await fetch("/api/session"); + const data = (await response.json()) as { authenticated: boolean }; + if (data.authenticated) { + router.replace("/dashboard"); + } + } catch { + // Silently fail - user stays on homepage + } + }; + + void checkAuth(); + }, [router]); + + return null; +}