From 65c9d4da7d1990866321ed5df4903bf78f4a26c0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Apr 2026 13:26:45 +0000 Subject: [PATCH] fix(docs): add canonical URLs to prevent SEO duplicate content The docs site has two deployments (production and dev) serving similar content. Add and pointing to the production domain on every page to signal search engines which version is authoritative. https://claude.ai/code/session_013JMAopahiPcfhPY7LxDmAo --- packages/docs/src/App.tsx | 51 ++++++++++++------- packages/docs/src/build.ts | 3 +- .../docs/src/components/Layout/Layout.tsx | 6 +++ packages/docs/src/constants.ts | 1 + 4 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 packages/docs/src/constants.ts diff --git a/packages/docs/src/App.tsx b/packages/docs/src/App.tsx index ccde776..79dd617 100644 --- a/packages/docs/src/App.tsx +++ b/packages/docs/src/App.tsx @@ -29,7 +29,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/", component: ( - + ), @@ -37,7 +37,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/getting-started", component: ( - + {defer(, { name: "GettingStarted" })} ), @@ -45,7 +45,10 @@ export const routes: RouteDefinition[] = [ route({ path: "/getting-started/migrating-from-vite-spa", component: ( - + {defer(, { name: "MigratingFromViteSPA" })} ), @@ -53,13 +56,15 @@ export const routes: RouteDefinition[] = [ route({ path: "/faq", component: ( - {defer(, { name: "FAQ" })} + + {defer(, { name: "FAQ" })} + ), }), route({ path: "/api/funstack-static", component: ( - + {defer(, { name: "FunstackStaticApi" })} ), @@ -67,7 +72,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/api/defer", component: ( - + {defer(, { name: "DeferApi" })} ), @@ -75,7 +80,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/api/build-entry", component: ( - + {defer(, { name: "BuildEntryApi" })} ), @@ -83,7 +88,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/api/entry-definition", component: ( - + {defer(, { name: "EntryDefinitionApi" })} ), @@ -91,7 +96,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/learn/how-it-works", component: ( - + {defer(, { name: "HowItWorks" })} ), @@ -99,7 +104,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/learn/rsc", component: ( - + {defer(, { name: "RSCConcept" })} ), @@ -107,7 +112,10 @@ export const routes: RouteDefinition[] = [ route({ path: "/learn/optimizing-payloads", component: ( - + {defer(, { name: "OptimizingPayloads" })} ), @@ -115,7 +123,10 @@ export const routes: RouteDefinition[] = [ route({ path: "/learn/lazy-server-components", component: ( - + {defer(, { name: "LazyServerComponents" })} ), @@ -123,7 +134,10 @@ export const routes: RouteDefinition[] = [ route({ path: "/learn/defer-and-activity", component: ( - + {defer(, { name: "DeferAndActivity" })} ), @@ -131,7 +145,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/learn/file-system-routing", component: ( - + {defer(, { name: "FileSystemRouting" })} ), @@ -139,7 +153,10 @@ export const routes: RouteDefinition[] = [ route({ path: "/advanced/multiple-entrypoints", component: ( - + {defer(, { name: "MultipleEntrypoints" })} ), @@ -147,7 +164,7 @@ export const routes: RouteDefinition[] = [ route({ path: "/advanced/ssr", component: ( - + {defer(, { name: "SSR" })} ), @@ -155,7 +172,7 @@ export const routes: RouteDefinition[] = [ route({ path: "*", component: ( - + ), diff --git a/packages/docs/src/build.ts b/packages/docs/src/build.ts index 620adb5..66d3d38 100644 --- a/packages/docs/src/build.ts +++ b/packages/docs/src/build.ts @@ -3,8 +3,7 @@ import path from "node:path"; import type { BuildEntryFunction } from "@funstack/static/server"; import type { RouteDefinition } from "@funstack/router/server"; import { routes } from "./App"; - -const siteUrl = "https://static.funstack.work"; +import { siteUrl } from "./constants"; function collectPaths(routes: RouteDefinition[]): string[] { const paths: string[] = []; diff --git a/packages/docs/src/components/Layout/Layout.tsx b/packages/docs/src/components/Layout/Layout.tsx index 76a5a2b..97ad036 100644 --- a/packages/docs/src/components/Layout/Layout.tsx +++ b/packages/docs/src/components/Layout/Layout.tsx @@ -1,5 +1,6 @@ import type React from "react"; import { Suspense } from "react"; +import { siteUrl } from "../../constants"; import { Header } from "../Header/Header"; import { MobileMenu } from "../MobileMenu/MobileMenu"; import { Sidebar } from "../Sidebar/Sidebar"; @@ -12,23 +13,28 @@ interface LayoutProps { children: React.ReactNode; variant?: LayoutVariant; title?: string; + path: string; } export const Layout: React.FC = ({ children, variant = "docs", title, + path, }) => { const layoutClass = variant === "home" ? styles.homeLayout : styles.docsLayout; const fullTitle = title ? `${title} | FUNSTACK Static` : "FUNSTACK Static - docs"; + const canonicalUrl = path === "/" ? `${siteUrl}/` : `${siteUrl}${path}`; return (
{fullTitle} + +
} />
diff --git a/packages/docs/src/constants.ts b/packages/docs/src/constants.ts new file mode 100644 index 0000000..0c43293 --- /dev/null +++ b/packages/docs/src/constants.ts @@ -0,0 +1 @@ +export const siteUrl = "https://static.funstack.work";