Files
bootnode/console/components/brand-provider.tsx
zeekayandHanzo Dev 7d293212cb refactor: web/ is now console/ — bootnode/bootnode is the backend, bootnode/console the frontend
Names the two halves for what they are. The repo already holds both (12407e9 merged
bootnode/bootnode into this history); this makes the frontend directory say so, so the layout
reads the way the owner describes the system: backend and frontend separate, one repo.

git mv throughout — 187 renames, history preserved. Every path reference follows: hanzo.yml
build context and dockerfile, compose.yml, compose.prod.yml, start.sh, LLM.md,
infra/k8s/web-deployments.yaml, infra/cloud/deploy.sh, and the Dockerfile's own COPY paths.
Image and container names (bootnode-web, the -web tag suffix) are deliberately NOT renamed here:
those are a deploy contract the App CR and ingress bind to on port 3001, and breaking them is a
separate, staged change.

Console builds green after the move; the Go tree builds.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-26 17:47:51 -07:00

43 lines
1.7 KiB
TypeScript

"use client"
// BrandProvider — publishes the hostname-resolved brand to the tree.
//
// `getBrand()` is already a pure function of the hostname, so this provider
// loads nothing: no /config.json fetch, no window.__BRAND_CATALOG__. It exists
// for exactly one reason — `output: "export"` prerenders every page with NO
// host, so the static HTML is necessarily the default brand. One
// post-hydration re-resolve swaps in the real one and re-renders every
// consumer. That is the whole job.
//
// It also owns the two brand-derived document facts a static <head> cannot
// know: the title and the favicon.
import { createContext, useContext, useEffect, useState } from "react"
import { getBrand, type BrandConfig } from "@/lib/brand"
const BrandContext = createContext<BrandConfig>(getBrand(""))
export function BrandProvider({ children }: { children: React.ReactNode }) {
// The first render must match the server's markup, so it uses the same
// host-less default; the effect below corrects it immediately after mount.
const [brand, setBrand] = useState<BrandConfig>(() => getBrand(""))
useEffect(() => {
const resolved = getBrand()
setBrand(resolved)
document.title = `${resolved.name} — ${resolved.tagline}`
document.querySelector<HTMLLinkElement>('link[rel="icon"]')?.setAttribute("href", resolved.favicon)
}, [])
return <BrandContext.Provider value={brand}>{children}</BrandContext.Provider>
}
/**
* The active brand, context-backed so every consumer re-renders when the
* hostname resolve lands. Components must use this rather than calling
* `getBrand()` directly, or they keep rendering the prerendered default.
*/
export function useBrand(): BrandConfig {
return useContext(BrandContext)
}