From d363ff5616822663ee221026ae66626b4ba80262 Mon Sep 17 00:00:00 2001 From: Brian Love Date: Fri, 5 Jun 2026 11:17:27 -0700 Subject: [PATCH 1/2] refactor(website): client-safe SITE_ORIGIN leaf module site-metadata.ts transitively imports lib/blog (Node fs), so it can't be imported from 'use client' components. Extract SITE_ORIGIN into a leaf module (site-origin.ts) with no fs-tainted imports; re-export it from site-metadata; import it in PageActions instead of the inline duplicate. Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/website/src/components/docs/PageActions.tsx | 6 +----- apps/website/src/lib/site-metadata.ts | 2 +- apps/website/src/lib/site-origin.ts | 4 ++++ 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 apps/website/src/lib/site-origin.ts diff --git a/apps/website/src/components/docs/PageActions.tsx b/apps/website/src/components/docs/PageActions.tsx index c3f9c9b6..d41fc448 100644 --- a/apps/website/src/components/docs/PageActions.tsx +++ b/apps/website/src/components/docs/PageActions.tsx @@ -3,11 +3,7 @@ import { useEffect, useRef, useState } from 'react'; import { tokens } from '@threadplane/design-tokens'; import { analyticsEvents } from '../../lib/analytics/events'; import { track } from '../../lib/analytics/client'; - -// NOTE: SITE_ORIGIN is duplicated from lib/site-metadata rather than imported, -// because site-metadata transitively pulls in lib/blog (Node `fs`), which a -// 'use client' component cannot bundle. Keep in sync with site-metadata.ts. -const SITE_ORIGIN = 'https://threadplane.ai'; +import { SITE_ORIGIN } from '../../lib/site-origin'; const GITHUB_EDIT_BASE = 'https://github.com/cacheplane/angular-agent-framework/edit/main/apps/website/content/docs'; diff --git a/apps/website/src/lib/site-metadata.ts b/apps/website/src/lib/site-metadata.ts index 120695f6..ea40c61c 100644 --- a/apps/website/src/lib/site-metadata.ts +++ b/apps/website/src/lib/site-metadata.ts @@ -3,7 +3,7 @@ import { getAllSolutionSlugs } from './solutions-data'; import { docsConfig } from './docs-config'; import { getAllPosts } from './blog'; -export const SITE_ORIGIN = 'https://threadplane.ai'; +export { SITE_ORIGIN } from './site-origin'; export const SITE_NAME = 'Threadplane'; export const DEFAULT_SOCIAL_IMAGE = '/opengraph-image'; export { diff --git a/apps/website/src/lib/site-origin.ts b/apps/website/src/lib/site-origin.ts new file mode 100644 index 00000000..36da0375 --- /dev/null +++ b/apps/website/src/lib/site-origin.ts @@ -0,0 +1,4 @@ +// Leaf module: the canonical site origin with NO Node-only (`fs`) imports, so it +// is safe to import from `'use client'` components. `site-metadata.ts` re-exports +// it; client code should import from here directly. +export const SITE_ORIGIN = 'https://threadplane.ai'; From 3862e2c802a41f7125c4007d927a917e37b52543 Mon Sep 17 00:00:00 2001 From: Brian Love Date: Fri, 5 Jun 2026 12:27:15 -0700 Subject: [PATCH 2/2] fix(website): import SITE_ORIGIN locally so site-metadata can use it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A bare `export { SITE_ORIGIN } from './site-origin'` re-export creates no local binding, but getCanonicalUrl() uses SITE_ORIGIN internally — `next build` failed with "Cannot find name 'SITE_ORIGIN'". Import then export. Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/website/src/lib/site-metadata.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/website/src/lib/site-metadata.ts b/apps/website/src/lib/site-metadata.ts index ea40c61c..60d19754 100644 --- a/apps/website/src/lib/site-metadata.ts +++ b/apps/website/src/lib/site-metadata.ts @@ -2,8 +2,9 @@ import type { Metadata } from 'next'; import { getAllSolutionSlugs } from './solutions-data'; import { docsConfig } from './docs-config'; import { getAllPosts } from './blog'; +import { SITE_ORIGIN } from './site-origin'; -export { SITE_ORIGIN } from './site-origin'; +export { SITE_ORIGIN }; export const SITE_NAME = 'Threadplane'; export const DEFAULT_SOCIAL_IMAGE = '/opengraph-image'; export {