From 9fd03458ad8c8c4048e0713559ec289a3ee35286 Mon Sep 17 00:00:00 2001 From: Jessica Winters Date: Fri, 4 Dec 2026 18:32:33 +0000 Subject: [PATCH 1/2] fix(docs-config): allow reo's third-party tracking scripts Reo's tag on coder.com has third-party tracking on. It loads the Sitelytics pixel from cdn.sitelytics.tech, which loads Sovrn's pixel from pxdrop.lijit.com, and the docs policy refused both on every page. Their beacons and Sovrn's iframe need no entry, since the policy sets only script-src. coder.com's site policy gets the same hosts in coder/coder-site. Assisted-by: AI --- packages/docs-config/src/analytics.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/docs-config/src/analytics.ts b/packages/docs-config/src/analytics.ts index 9e52fa46..61e1efd1 100644 --- a/packages/docs-config/src/analytics.ts +++ b/packages/docs-config/src/analytics.ts @@ -62,6 +62,9 @@ export const ANALYTICS_SCRIPT_ORIGINS: readonly string[] = [ "https://static.hotjar.com", // Hotjar's surveys (survey-v2.*.js), measured on coder.com/docs on 2026-11-30. "https://script.hj.contentsquare.net", + // Reo's third-party tracking: the Sitelytics pixel and the Sovrn pixel it loads, measured on coder.com/docs on 2026-12-04. + "https://cdn.sitelytics.tech", + "https://pxdrop.lijit.com", ]; /** From f7a5efe91eea8129eb5fef2f79b0a6fd4e969259 Mon Sep 17 00:00:00 2001 From: Jessica Winters Date: Fri, 4 Dec 2026 18:32:33 +0000 Subject: [PATCH 2/2] fix(docs-next): leave full urls to the browser instead of next's link The icon bar's Coder home mark is a fumadocs link item with external set to false, so it renders through Next's Link. On coder.com the docs and the main site share an origin, so Next treats https://coder.com/ as a page of the docs app and prefetches it, which answers 404 for /__next._tree.txt in every reader's console. DocsProvider now gives fumadocs a framework link that renders a full URL as a plain anchor and keeps Next's Link for paths. Fumadocs already renders full URLs it marks external as plain anchors, so only items that opt out reach this branch. Assisted-by: AI --- packages/docs-next/src/docs-link.test.tsx | 37 +++++++++++++++++++++++ packages/docs-next/src/docs-link.tsx | 26 ++++++++++++++++ packages/docs-next/src/provider.test.tsx | 11 +++++++ packages/docs-next/src/provider.tsx | 2 ++ 4 files changed, 76 insertions(+) create mode 100644 packages/docs-next/src/docs-link.test.tsx create mode 100644 packages/docs-next/src/docs-link.tsx diff --git a/packages/docs-next/src/docs-link.test.tsx b/packages/docs-next/src/docs-link.test.tsx new file mode 100644 index 00000000..50008ac3 --- /dev/null +++ b/packages/docs-next/src/docs-link.test.tsx @@ -0,0 +1,37 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import type { ComponentProps } from "react"; +import { renderToFragment } from "../test/dom.js"; +import { withPlainAbsoluteLinks } from "./docs-link.js"; + +function AppLink({ href, children, ...props }: ComponentProps<"a">) { + return ( + + {children} + + ); +} +const DocsLink = withPlainAbsoluteLinks(AppLink); + +test("a full URL is a plain anchor, so the docs app never prefetches or routes it", () => { + for (const href of ["https://coder.com/", "https://coder.com/pricing", "//coder.com/"]) { + const link = renderToFragment( + + home + , + ).querySelector("a"); + assert.equal(link?.hasAttribute("data-app-link"), false, href); + assert.equal(link?.getAttribute("href"), href); + assert.equal(link?.getAttribute("aria-label"), "Coder home"); + assert.equal(link?.getAttribute("class"), "mark"); + assert.equal(link?.textContent, "home"); + } +}); + +test("a path in the docs keeps the app's link", () => { + for (const href of ["/", "/install", "#top"]) { + const link = renderToFragment(page).querySelector("a"); + assert.equal(link?.hasAttribute("data-app-link"), true, href); + assert.equal(link?.getAttribute("href"), href); + } +}); diff --git a/packages/docs-next/src/docs-link.tsx b/packages/docs-next/src/docs-link.tsx new file mode 100644 index 00000000..be10385a --- /dev/null +++ b/packages/docs-next/src/docs-link.tsx @@ -0,0 +1,26 @@ +"use client"; +import NextLink from "next/link"; +import type { ComponentProps, FC } from "react"; + +type LinkProps = ComponentProps<"a"> & { prefetch?: boolean }; + +/** Fumadocs' framework link, with full URLs left to the browser: Next would treat a same-origin one as a docs page and prefetch it. */ +export function withPlainAbsoluteLinks(AppLink: FC): FC { + return function DocsLink({ href, prefetch, children, ...props }: LinkProps) { + if (href !== undefined && (/^\w+:/.test(href) || href.startsWith("//"))) + return ( + + {children} + + ); + return ( + + {children} + + ); + }; +} + +export const DocsLink = withPlainAbsoluteLinks(({ href = "#", ...props }) => ( + +)); diff --git a/packages/docs-next/src/provider.test.tsx b/packages/docs-next/src/provider.test.tsx index 6bfac846..c2435b4e 100644 --- a/packages/docs-next/src/provider.test.tsx +++ b/packages/docs-next/src/provider.test.tsx @@ -5,6 +5,7 @@ import type { RootProvider } from "fumadocs-ui/provider/next"; import type { ComponentProps } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { renderToFragment } from "../test/dom.js"; +import { DocsLink } from "./docs-link.js"; import { DocsProvider } from "./provider.js"; // A stand-in for the fumadocs RootProvider that records the props it receives @@ -152,6 +153,16 @@ test("options.provider replaces the default fumadocs RootProvider", () => { assert.equal(out.querySelector("[data-stub-provider='true']")?.textContent, "content"); }); +test("fumadocs' links render through the docs link, so a full URL stays a plain anchor", () => { + captured.props = undefined; + renderToStaticMarkup( + + + , + ); + assert.equal(getCaptured()?.components?.Link, DocsLink); +}); + test("options.search.hybrid swaps in the hybrid search dialog", () => { renderToStaticMarkup( diff --git a/packages/docs-next/src/provider.tsx b/packages/docs-next/src/provider.tsx index 0c6b55c3..4658da3a 100644 --- a/packages/docs-next/src/provider.tsx +++ b/packages/docs-next/src/provider.tsx @@ -8,6 +8,7 @@ import type { SearchProviderProps } from "fumadocs-ui/contexts/search"; import { RootProvider } from "fumadocs-ui/provider/next"; import type { ComponentProps, ComponentType, ReactNode } from "react"; import { lazy } from "react"; +import { DocsLink } from "./docs-link.js"; // Its own chunk, so a provider without `hybrid` never downloads it. const HybridSearchDialog = lazy(() => import("./hybrid-search.js")); @@ -106,6 +107,7 @@ export function DocsProvider({ const Provider = options?.provider ?? RootProvider; const providerProps: FumadocsRootProviderProps = { search: buildSearchProp(options?.search), + components: { Link: DocsLink }, ...(options?.theme !== undefined ? { theme: options.theme } : {}), }; return (