Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<main className="flex min-h-[calc(100vh-4rem)] flex-col justify-between">
<AuthRedirect />
<HomeHero
googleClientId={process.env.GOOGLE_OAUTH_CLIENT_ID ?? ""}
toast={toast}
Expand Down
17 changes: 17 additions & 0 deletions app/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { MetadataRoute } from "next";

export default function robots(): MetadataRoute.Robots {
const baseUrl =
process.env.TRIVET_PUBLIC_BASE_URL ?? "https://trivet.contraption.co";

return {
rules: [
{
userAgent: "*",
allow: "/",
disallow: ["/api/", "/dashboard", "/settings", "/onboarding/"]
}
],
sitemap: `${baseUrl}/sitemap.xml`
};
}
15 changes: 15 additions & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { MetadataRoute } from "next";

export default function sitemap(): MetadataRoute.Sitemap {
const baseUrl =
process.env.TRIVET_PUBLIC_BASE_URL ?? "https://trivet.contraption.co";

return [
{
url: baseUrl,
lastModified: new Date(),
changeFrequency: "monthly",
priority: 1
}
];
}
30 changes: 30 additions & 0 deletions components/auth-redirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";

import { useEffect } from "react";
import { useRouter } from "next/navigation";

/**
* Client-side component that redirects authenticated users to the dashboard.
* Used on the homepage to allow static rendering while still handling auth redirects.
*/
export function AuthRedirect() {
const router = useRouter();

useEffect(() => {
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;
}