Documentation Catalog
Developer documentation hub featuring a searchable hero banner, CLI starter panel, quick-start cards, filterable categorized guide tracks with schematic previews, interactive article preview dialog with copyable code blocks, and live status and changelog links.
v3.4Harbor Edge Developer Docs
Build, deploy, and observe low-latency edge workers, durable caches, and zero-trust APIs across 42 global PoPs.
npx harbor init my-edge-appGetting Started
4Project setup, local emulation, secrets, and your first global deployment.
Runtime & Edge
4Isolate execution, streaming I/O, distributed KV caching, and scheduled triggers.
SDK Reference
4Typed client libraries, request context primitives, middleware, and OpenTelemetry.
Security & Auth
4Edge token verification, passkeys, HMAC webhooks, and programmable rate limits.
Install
1npx stylexblocks add documentation-catalogSource
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041import * as stylex from "@stylexjs/stylex";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { Center, Square } from "#components/ui/ui-sdk/center.tsx";import { Code } from "#components/ui/ui-sdk/code.tsx";import { CodeBlock } from "#components/ui/ui-sdk/code-block.tsx";import { Dialog } from "#components/ui/ui-sdk/dialog.tsx";import { EmptyState } from "#components/ui/ui-sdk/empty-state.tsx";import { Grid } from "#components/ui/ui-sdk/grid.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { Icon } from "#components/ui/ui-sdk/icon.tsx";import { IconBadge } from "#components/ui/ui-sdk/icon-badge.tsx";import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";import { Input } from "#components/ui/ui-sdk/input.tsx";import { Kbd } from "#components/ui/ui-sdk/kbd.tsx";import { Link } from "#components/ui/ui-sdk/link.tsx";import { Section } from "#components/ui/ui-sdk/section.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Status } from "#components/ui/ui-sdk/status.tsx";import { Tag } from "#components/ui/ui-sdk/tag.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";import { accentPalette, emeraldPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { durations } from "@stylexblocks/ui/tokens/durations.stylex.ts";import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
// ---------------------------------------------------------------------------// Types// ---------------------------------------------------------------------------
export type DocTrackId = | "getting-started" | "runtime-edge" | "sdk-reference" | "security-auth";
export type DocDiagramKind = | "deploy" | "config" | "emulator" | "secrets" | "isolate" | "stream" | "kv" | "cron" | "client-sdk" | "request-ctx" | "middleware" | "telemetry" | "zero-trust" | "passkeys" | "webhooks" | "waf";
export interface DocGuide { id: string; trackId: DocTrackId; title: string; description: string; overview: string; readTime: string; badge?: string; version: string; updatedLabel: string; topics: string[]; filename: string; snippet: string; diagram: DocDiagramKind;}
export interface DocTrack { id: DocTrackId; label: string; description: string; items: DocGuide[];}
export interface QuickStartCardItem { id: string; guideId: string; title: string; description: string; command: string; duration: string; icon: "rocket" | "terminal" | "package";}
export interface DocumentationCatalogProps extends StyleOverrideProps { /** Product / documentation hub title shown in the hero banner. */ title?: string; /** Supporting subtitle copy inside the hero banner. */ subtitle?: string; /** Current SDK / runtime version badge. */ version?: string; /** Categorized documentation tracks. */ tracks?: readonly DocTrack[]; /** Quick-start cards surfaced directly beneath the hero banner. */ quickStarts?: readonly QuickStartCardItem[]; /** Called when the user activates "Open full guide" for an article. */ onOpenGuide?: (guide: DocGuide) => void;}
// ---------------------------------------------------------------------------// Demo data — Harbor Edge Developer Docs// ---------------------------------------------------------------------------
const DEFAULT_QUICK_STARTS: readonly QuickStartCardItem[] = [ { id: "qs-deploy", guideId: "quickstart-deployment", title: "Deploy your first worker", description: "Scaffold an edge handler and publish globally across 42 PoPs.", command: "npx harbor init my-worker", duration: "5 min", icon: "rocket", }, { id: "qs-emulator", guideId: "local-edge-emulator", title: "Run the local emulator", description: "Develop offline with V8 isolates, simulated KV, and trace replay.", command: "harbor dev --inspect", duration: "3 min", icon: "terminal", }, { id: "qs-sdk", guideId: "harbor-client-sdk", title: "Install the typed SDK", description: "Invoke edge functions and durable caches from TypeScript apps.", command: "bun add @harbor-edge/sdk", duration: "4 min", icon: "package", },];
const DEFAULT_TRACKS: readonly DocTrack[] = [ { id: "getting-started", label: "Getting Started", description: "Project setup, local emulation, secrets, and your first global deployment.", items: [ { id: "quickstart-deployment", trackId: "getting-started", title: "Quickstart Deployment", description: "Scaffold a TypeScript edge worker, verify routes locally, and publish an immutable global release in under five minutes.", overview: "Harbor Edge bundles your TypeScript entrypoint into a compact ES module and distributes it to every regional PoP atomically. Each deployment receives an immutable preview URL before promotion to production.", readTime: "5 min", badge: "Start here", version: "v3.4", updatedLabel: "2 days ago", topics: ["CLI", "Deployments", "Preview URLs"], filename: "src/index.ts", snippet: `import { defineWorker } from "@harbor-edge/runtime";
export default defineWorker({ async fetch(request, ctx) { return Response.json({ region: ctx.geo.pop, requestId: ctx.requestId, ok: true, }); },});`, diagram: "deploy", }, { id: "project-configuration", trackId: "getting-started", title: "Project Configuration", description: "Define route matchers, regional placement hints, compatibility dates, and KV namespace bindings inside harbor.config.ts.", overview: "A single typed configuration file describes your runtime compatibility flags, build pipeline hooks, and resource bindings across local, preview, and production environments.", readTime: "4 min", version: "v3.4", updatedLabel: "5 days ago", topics: ["harbor.config.ts", "Bindings", "Regions"], filename: "harbor.config.ts", snippet: `import { defineConfig } from "@harbor-edge/cli";
export default defineConfig({ name: "billing-edge-api", compatibilityDate: "2026-11-01", placement: "smart", kv: [{ binding: "SESSION_KV", id: "kv_01j9x7" }],});`, diagram: "config", }, { id: "local-edge-emulator", trackId: "getting-started", title: "Local Edge Emulator", description: "Run the same isolate runtime locally with sub-second hot reload, persisted SQLite-backed KV, and deterministic request replay.", overview: "Avoid staging round-trips by executing edge handlers inside a local sandbox that mirrors production memory caps, headers, and cron schedules.", readTime: "6 min", version: "v3.4", updatedLabel: "1 week ago", topics: ["Dev Server", "Hot Reload", "Inspector"], filename: "terminal", snippet: `# Start the local runtime with Chrome DevTools attachedharbor dev --port 8787 --inspect
# Replay a captured production trace locallyharbor replay tr_94f1c2 --env local`, diagram: "emulator", }, { id: "environment-secrets", trackId: "getting-started", title: "Environment & Secrets", description: "Inject encrypted runtime secrets per deployment stage with instant key rotation and zero artifact rebuilds.", overview: "Secrets are envelope-encrypted at rest and decrypted only inside the target isolate's memory space. Stage overrides let preview branches stay isolated from production credentials.", readTime: "4 min", version: "v3.3", updatedLabel: "2 weeks ago", topics: ["Secrets", "Stages", "Rotation"], filename: "terminal", snippet: `# Set a secret for production without redeployingharbor secret set STRIPE_WEBHOOK_KEY --stage prod
# List bound secret keys (values are never printed)harbor secret list --stage prod`, diagram: "secrets", }, ], }, { id: "runtime-edge", label: "Runtime & Edge", description: "Isolate execution, streaming I/O, distributed KV caching, and scheduled triggers.", items: [ { id: "isolate-execution-model", trackId: "runtime-edge", title: "Isolate Execution Model", description: "Understand sub-18 ms cold starts, per-request CPU budgets, memory ceilings, and ctx.waitUntil background tasks.", overview: "Harbor executes handlers in lightweight V8 isolates rather than container VMs. Use ctx.waitUntil to flush telemetry or cache writes after the HTTP response completes.", readTime: "7 min", version: "v3.4", updatedLabel: "4 days ago", topics: ["V8 Isolates", "Lifecycle", "waitUntil"], filename: "src/worker.ts", snippet: `export default defineWorker({ async fetch(req, ctx) { const res = await handleApi(req); ctx.waitUntil(ctx.analytics.flush({ status: res.status })); return res; },});`, diagram: "isolate", }, { id: "streaming-responses", trackId: "runtime-edge", title: "Streaming Responses", description: "Stream server-sent events, chunked HTML, and AI token output straight from edge PoPs with automatic backpressure.", overview: "Web Standards ReadableStream and TransformStream run natively with zero buffering overhead, keeping time-to-first-byte low even for long-lived model responses.", readTime: "6 min", badge: "New", version: "v3.4", updatedLabel: "3 days ago", topics: ["SSE", "ReadableStream", "Backpressure"], filename: "src/stream.ts", snippet: `const stream = new ReadableStream({ async start(controller) { for await (const chunk of generateTokens()) { controller.enqueue(\`data: \${chunk}\\n\\n\`); } controller.close(); },});
return new Response(stream, { headers: { "content-type": "text/event-stream" },});`, diagram: "stream", }, { id: "kv-durable-cache", trackId: "runtime-edge", title: "KV & Durable Cache", description: "Read globally replicated key-value entries in single-digit milliseconds and coordinate atomic writes with durable locks.", overview: "Pair high-fanout read-mostly edge KV with single-writer durable coordinators for counters, rate buckets, and collaborative state.", readTime: "8 min", version: "v3.4", updatedLabel: "6 days ago", topics: ["Edge KV", "TTL", "Atomic Writes"], filename: "src/cache.ts", snippet: `const cached = await ctx.kv.SESSION_KV.get("flags:v2", { type: "json", cacheTtl: 60,});
if (!cached) { await ctx.kv.SESSION_KV.put("flags:v2", JSON.stringify(flags), { expirationTtl: 300, });}`, diagram: "kv", }, { id: "scheduled-cron-triggers", trackId: "runtime-edge", title: "Scheduled Cron Triggers", description: "Run recurring cache warmers, billing reconciliations, and webhook sweeps on standard UTC cron schedules.", overview: "Scheduled invocations execute with built-in idempotency keys and automatic exponential retry when an upstream dependency times out.", readTime: "5 min", version: "v3.3", updatedLabel: "1 week ago", topics: ["Cron", "Retries", "Idempotency"], filename: "src/cron.ts", snippet: `export default defineWorker({ scheduled: { "*/15 * * * *": async (event, ctx) => { await warmRegionalCatalogs(ctx.kv.CATALOG_KV, event.scheduledTime); }, },});`, diagram: "cron", }, ], }, { id: "sdk-reference", label: "SDK Reference", description: "Typed client libraries, request context primitives, middleware, and OpenTelemetry.", items: [ { id: "harbor-client-sdk", trackId: "sdk-reference", title: "Harbor Client SDK", description: "Call edge workers, manage KV namespaces, and stream deployment logs from Bun, Node.js, or browser clients.", overview: "The official @harbor-edge/sdk package ships zero runtime dependencies, end-to-end TypeScript inference, and automatic request retries with jitter.", readTime: "6 min", badge: "API", version: "v3.4", updatedLabel: "1 day ago", topics: ["TypeScript", "Client", "Retries"], filename: "lib/harbor.ts", snippet: `import { createHarborClient } from "@harbor-edge/sdk";
export const harbor = createHarborClient({ token: process.env.HARBOR_API_TOKEN!, region: "auto",});
const result = await harbor.workers.invoke("pricing-calc", { payload: { currency: "EUR", seats: 24 },});`, diagram: "client-sdk", }, { id: "request-context-api", trackId: "sdk-reference", title: "Request & Context API", description: "Inspect parsed geolocation metadata, TLS cipher details, typed route params, and per-request cancellation signals.", overview: "Every handler receives a frozen ExecutionContext containing PoP identifiers, ASN metadata, and an AbortSignal wired to client disconnects.", readTime: "5 min", version: "v3.4", updatedLabel: "9 days ago", topics: ["Geo", "AbortSignal", "Headers"], filename: "src/geo.ts", snippet: `export async function GET(req: Request, ctx: HarborContext) { const { country, city, pop } = ctx.geo; return Response.json({ servedBy: pop, visitor: \`\${city}, \${country}\`, });}`, diagram: "request-ctx", }, { id: "edge-middleware", trackId: "sdk-reference", title: "Edge Middleware", description: "Compose authentication guards, A/B cookie bucketing, and response header rewrites cleanly across route trees.", overview: "Chain small, testable middleware functions that short-circuit unauthorized requests or enrich downstream context before handlers execute.", readTime: "6 min", version: "v3.4", updatedLabel: "5 days ago", topics: ["Middleware", "Routing", "Headers"], filename: "src/middleware.ts", snippet: `import { composeMiddleware } from "@harbor-edge/runtime";
export const withSecurityHeaders = composeMiddleware(async (req, ctx, next) => { const response = await next(); response.headers.set("x-frame-options", "DENY"); response.headers.set("x-edge-pop", ctx.geo.pop); return response;});`, diagram: "middleware", }, { id: "structured-telemetry", trackId: "sdk-reference", title: "Structured Telemetry", description: "Export OpenTelemetry traces, custom p99 latency histograms, and JSON log streams to OTLP-compatible backends.", overview: "Capture distributed spans with traceparent propagation out of the box without adding noticeable overhead to hot request paths.", readTime: "7 min", version: "v3.4", updatedLabel: "4 days ago", topics: ["OpenTelemetry", "Logs", "Metrics"], filename: "src/telemetry.ts", snippet: `import { trace } from "@harbor-edge/telemetry";
export async function loadInvoice(id: string) { return trace("db.load_invoice", { invoiceId: id }, async (span) => { const row = await fetchInvoice(id); span.setAttribute("invoice.currency", row.currency); return row; });}`, diagram: "telemetry", }, ], }, { id: "security-auth", label: "Security & Auth", description: "Edge token verification, passkeys, HMAC webhooks, and programmable rate limits.", items: [ { id: "zero-trust-tokens", trackId: "security-auth", title: "Zero-Trust Tokens", description: "Verify short-lived Ed25519 JWTs at the edge using cached JWKS bundles before requests ever reach your origin.", overview: "Reject expired or tampered credentials at the closest PoP using WebCrypto subtle verification and automatic background JWKS refresh.", readTime: "6 min", badge: "Security", version: "v3.4", updatedLabel: "3 days ago", topics: ["Ed25519", "JWKS", "Zero-Trust"], filename: "src/auth.ts", snippet: `import { verifyEdgeJwt } from "@harbor-edge/auth";
const claims = await verifyEdgeJwt(request.headers.get("authorization"), { issuer: "https://auth.harboredge.dev", audience: "harbor-api", jwksCacheTtl: 600,});`, diagram: "zero-trust", }, { id: "oauth-passkeys", trackId: "security-auth", title: "OAuth & Passkeys", description: "Implement WebAuthn passkey sign-in and PKCE OAuth callbacks with encrypted httpOnly edge session cookies.", overview: "Store compact revocation lists in edge KV so signed-out sessions invalidate globally in under two seconds.", readTime: "8 min", version: "v3.4", updatedLabel: "1 week ago", topics: ["WebAuthn", "PKCE", "Sessions"], filename: "src/passkey.ts", snippet: `import { createPasskeyChallenge } from "@harbor-edge/auth";
export async function POST(req: Request, ctx: HarborContext) { const challenge = await createPasskeyChallenge({ rpId: "app.harboredge.dev", kv: ctx.kv.AUTH_CHALLENGES, ttlSeconds: 180, }); return Response.json(challenge);}`, diagram: "passkeys", }, { id: "webhook-signatures", trackId: "security-auth", title: "Webhook Signatures", description: "Validate HMAC-SHA256 webhook payloads with constant-time digests and configurable timestamp replay windows.", overview: "Verify raw request bytes prior to JSON parsing so forged or replayed third-party callbacks are dropped immediately.", readTime: "4 min", version: "v3.3", updatedLabel: "2 weeks ago", topics: ["HMAC-SHA256", "Replay Guard", "Webhooks"], filename: "src/webhook.ts", snippet: `import { verifyHmacSignature } from "@harbor-edge/auth";
const rawBody = await request.text();const valid = await verifyHmacSignature({ payload: rawBody, signature: request.headers.get("x-harbor-signature"), secret: ctx.env.WEBHOOK_SECRET, toleranceSeconds: 300,});`, diagram: "webhooks", }, { id: "rate-limiting-waf", trackId: "security-auth", title: "Rate Limiting & WAF", description: "Enforce sliding-window quotas per API key or subnet alongside managed bot mitigation and custom WAF rules.", overview: "Combine deterministic token-bucket counters with standard Retry-After headers so abusive spikes never starve legitimate API traffic.", readTime: "6 min", version: "v3.4", updatedLabel: "5 days ago", topics: ["Token Bucket", "WAF", "Quotas"], filename: "src/ratelimit.ts", snippet: `import { rateLimit } from "@harbor-edge/shield";
const decision = await rateLimit(ctx.bindings.API_LIMITER, { key: ctx.auth.apiKeyId ?? ctx.clientIp, limit: 120, windowSeconds: 60,});
if (!decision.allowed) { return new Response("Too many requests", { status: 429 });}`, diagram: "waf", }, ], },];
// ---------------------------------------------------------------------------// Inline SVG Icons (zero external icon packages)// ---------------------------------------------------------------------------
function HarborMarkIcon() { return ( <Icon size="md" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="12" cy="5.5" r="2.25" /> <path d="M12 7.75V20" /> <path d="M5.5 13.5a6.5 6.5 0 0 0 13 0" /> <path d="M4 13.5h3" /> <path d="M17 13.5h3" /> </Icon> );}
function SearchIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="9" cy="9" r="5.5" /> <path d="m13.2 13.2 3.3 3.3" /> </Icon> );}
function CloseIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M5.5 5.5 14.5 14.5" /> <path d="M14.5 5.5 5.5 14.5" /> </Icon> );}
function ArrowRightIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M4.5 10h11" /> <path d="M11 5.5 15.5 10 11 14.5" /> </Icon> );}
function CopyIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="7" y="7" width="9" height="9" rx="1.75" /> <path d="M4 13V5.5A1.5 1.5 0 0 1 5.5 4H13" /> </Icon> );}
function CheckIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.85" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m5 10.5 3.2 3.2L15.5 6.5" /> </Icon> );}
function BookmarkIcon({ filled }: { filled: boolean }) { return ( <Icon size="sm" viewBox="0 0 20 20" fill={filled ? "currentColor" : "none"} stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M5.5 4.25A1.25 1.25 0 0 1 6.75 3h6.5a1.25 1.25 0 0 1 1.25 1.25V17l-4.5-3-4.5 3V4.25Z" /> </Icon> );}
function QuickStartIcon({ kind }: { kind: QuickStartCardItem["icon"] }) { if (kind === "rocket") { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M11.5 8.5 16 4c.4 3.4-.9 6.5-3.3 8.8l-1.7 1.7-3.5-3.5 1.7-1.7Z" /> <path d="M7.5 11 4.5 11.5 3.5 16.5l5-1 .5-3" /> <circle cx="12.5" cy="7.5" r="1" /> </Icon> ); } if (kind === "terminal") { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="2.75" y="4" width="14.5" height="12" rx="2" /> <path d="m6.25 8.25 2.5 2-2.5 2" /> <path d="M10.5 12.25h3.25" /> </Icon> ); } return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m10 2.75 6.25 3.5v7.5L10 17.25l-6.25-3.5v-7.5L10 2.75Z" /> <path d="M10 10 16.25 6.25" /> <path d="M10 10 3.75 6.25" /> <path d="M10 10v7.25" /> </Icon> );}
// ---------------------------------------------------------------------------// Minimalist, theme-adaptive SVG schematic previews for each guide card// ---------------------------------------------------------------------------
function GuidePreviewDiagram({ kind }: { kind: DocDiagramKind }) { return ( <svg viewBox="0 0 320 156" fill="none" aria-hidden="true" {...stylex.props(styles.diagramSvg)} > <defs> <pattern id={`dots-${kind}`} width="16" height="16" patternUnits="userSpaceOnUse" > <circle cx="2" cy="2" r="0.9" fill="currentColor" opacity="0.14" /> </pattern> </defs> <rect width="320" height="156" fill={`url(#dots-${kind})`} />
{kind === "deploy" ? ( <g stroke="currentColor" strokeWidth="1.4"> <rect x="34" y="54" width="66" height="48" rx="8" fill="currentColor" fillOpacity="0.06" opacity="0.55" /> <path d="M52 72h30M52 84h20" strokeLinecap="round" opacity="0.65" /> <path d="M100 78h40" strokeDasharray="3 3" opacity="0.55" /> <circle cx="160" cy="78" r="20" fill="currentColor" fillOpacity="0.1" opacity="0.85" /> <path d="M153 78l5 5 10-10" strokeLinecap="round" strokeLinejoin="round" /> <path d="M180 78h38" strokeDasharray="3 3" opacity="0.55" /> <rect x="218" y="42" width="68" height="22" rx="6" fill="currentColor" fillOpacity="0.07" opacity="0.6" /> <rect x="218" y="70" width="68" height="22" rx="6" fill="currentColor" fillOpacity="0.07" opacity="0.6" /> <rect x="218" y="98" width="68" height="22" rx="6" fill="currentColor" fillOpacity="0.07" opacity="0.6" /> </g> ) : null}
{kind === "config" ? ( <g stroke="currentColor" strokeWidth="1.4"> <rect x="52" y="28" width="216" height="100" rx="10" fill="currentColor" fillOpacity="0.05" opacity="0.65" /> <line x1="52" y1="52" x2="268" y2="52" opacity="0.3" /> <circle cx="68" cy="40" r="3" fill="currentColor" opacity="0.35" /> <circle cx="80" cy="40" r="3" fill="currentColor" opacity="0.25" /> <path d="M74 72h42M124 72h62" strokeLinecap="round" opacity="0.7" /> <path d="M88 90h56M152 90h40" strokeLinecap="round" opacity="0.5" /> <path d="M88 108h36M132 108h78" strokeLinecap="round" opacity="0.4" /> </g> ) : null}
{kind === "emulator" ? ( <g stroke="currentColor" strokeWidth="1.4"> <rect x="44" y="30" width="232" height="96" rx="10" fill="currentColor" fillOpacity="0.05" opacity="0.65" /> <path d="m68 62 12 10-12 10" strokeLinecap="round" strokeLinejoin="round" opacity="0.85" /> <path d="M90 82h66" strokeLinecap="round" opacity="0.7" /> <rect x="68" y="96" width="184" height="14" rx="4" fill="currentColor" fillOpacity="0.08" opacity="0.45" /> <circle cx="248" cy="48" r="4" fill="currentColor" opacity="0.5" /> </g> ) : null}
{kind === "secrets" ? ( <g stroke="currentColor" strokeWidth="1.4"> <rect x="76" y="42" width="168" height="72" rx="10" fill="currentColor" fillOpacity="0.05" opacity="0.65" /> <rect x="144" y="64" width="32" height="26" rx="5" fill="currentColor" fillOpacity="0.1" opacity="0.85" /> <path d="M152 64v-6a8 8 0 0 1 16 0v6" strokeLinecap="round" opacity="0.8" /> <circle cx="104" cy="78" r="3" fill="currentColor" opacity="0.45" /> <circle cx="116" cy="78" r="3" fill="currentColor" opacity="0.45" /> <circle cx="128" cy="78" r="3" fill="currentColor" opacity="0.45" /> <circle cx="192" cy="78" r="3" fill="currentColor" opacity="0.45" /> <circle cx="204" cy="78" r="3" fill="currentColor" opacity="0.45" /> <circle cx="216" cy="78" r="3" fill="currentColor" opacity="0.45" /> </g> ) : null}
{kind === "isolate" ? ( <g stroke="currentColor" strokeWidth="1.4"> <circle cx="160" cy="78" r="48" strokeDasharray="4 4" opacity="0.35" /> <circle cx="160" cy="78" r="30" fill="currentColor" fillOpacity="0.06" opacity="0.7" /> <circle cx="160" cy="78" r="12" fill="currentColor" fillOpacity="0.14" opacity="0.9" /> <circle cx="160" cy="30" r="4" fill="currentColor" opacity="0.6" /> <circle cx="208" cy="78" r="4" fill="currentColor" opacity="0.6" /> <circle cx="160" cy="126" r="4" fill="currentColor" opacity="0.6" /> <circle cx="112" cy="78" r="4" fill="currentColor" opacity="0.6" /> </g> ) : null}
{kind === "stream" ? ( <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round"> <path d="M40 56c26-16 54-16 80 0s54 16 80 0 54-16 80 0" opacity="0.4" /> <path d="M40 78c26-16 54-16 80 0s54 16 80 0 54-16 80 0" opacity="0.85" /> <path d="M40 100c26-16 54-16 80 0s54 16 80 0 54-16 80 0" opacity="0.4" /> <circle cx="120" cy="78" r="4" fill="currentColor" /> <circle cx="200" cy="78" r="4" fill="currentColor" opacity="0.7" /> </g> ) : null}
{kind === "kv" ? ( <g stroke="currentColor" strokeWidth="1.4"> <rect x="48" y="34" width="66" height="38" rx="7" fill="currentColor" fillOpacity="0.06" opacity="0.65" /> <rect x="127" y="34" width="66" height="38" rx="7" fill="currentColor" fillOpacity="0.11" opacity="0.85" /> <rect x="206" y="34" width="66" height="38" rx="7" fill="currentColor" fillOpacity="0.06" opacity="0.65" /> <rect x="48" y="84" width="66" height="38" rx="7" fill="currentColor" fillOpacity="0.06" opacity="0.65" /> <rect x="127" y="84" width="66" height="38" rx="7" fill="currentColor" fillOpacity="0.06" opacity="0.65" /> <rect x="206" y="84" width="66" height="38" rx="7" fill="currentColor" fillOpacity="0.09" opacity="0.8" /> <path d="M64 53h34M143 53h34M222 53h34M64 103h34M143 103h34M222 103h34" strokeLinecap="round" opacity="0.5" /> </g> ) : null}
{kind === "cron" ? ( <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round"> <circle cx="160" cy="78" r="40" fill="currentColor" fillOpacity="0.05" opacity="0.7" /> <path d="M160 54v24l16 10" opacity="0.9" /> <path d="M160 28v6M160 122v6M110 78h6M204 78h6" opacity="0.45" /> <path d="M72 78h24M224 78h24" strokeDasharray="3 3" opacity="0.4" /> </g> ) : null}
{kind === "client-sdk" ? ( <g stroke="currentColor" strokeWidth="1.4"> <rect x="42" y="48" width="76" height="60" rx="8" fill="currentColor" fillOpacity="0.06" opacity="0.7" /> <rect x="202" y="48" width="76" height="60" rx="8" fill="currentColor" fillOpacity="0.09" opacity="0.85" /> <path d="M118 68h84" strokeLinecap="round" opacity="0.75" /> <path d="m194 62 8 6-8 6" strokeLinecap="round" strokeLinejoin="round" opacity="0.75" /> <path d="M202 88h-84" strokeLinecap="round" strokeDasharray="4 3" opacity="0.55" /> <path d="m126 82-8 6 8 6" strokeLinecap="round" strokeLinejoin="round" opacity="0.55" /> <path d="M58 72h38M58 86h26M218 72h42M218 86h30" strokeLinecap="round" opacity="0.55" /> </g> ) : null}
{kind === "request-ctx" ? ( <g stroke="currentColor" strokeWidth="1.4"> <circle cx="104" cy="78" r="34" fill="currentColor" fillOpacity="0.05" opacity="0.65" /> <ellipse cx="104" cy="78" rx="16" ry="34" opacity="0.35" /> <line x1="70" y1="78" x2="138" y2="78" opacity="0.35" /> <rect x="164" y="42" width="110" height="72" rx="8" fill="currentColor" fillOpacity="0.06" opacity="0.75" /> <path d="M180 62h54M180 78h74M180 94h42" strokeLinecap="round" opacity="0.6" /> </g> ) : null}
{kind === "middleware" ? ( <g stroke="currentColor" strokeWidth="1.4"> <rect x="38" y="48" width="52" height="60" rx="8" fill="currentColor" fillOpacity="0.05" opacity="0.6" /> <rect x="134" y="40" width="52" height="76" rx="8" fill="currentColor" fillOpacity="0.1" opacity="0.85" /> <rect x="230" y="48" width="52" height="60" rx="8" fill="currentColor" fillOpacity="0.05" opacity="0.6" /> <path d="M90 78h44M186 78h44" strokeLinecap="round" opacity="0.7" /> <circle cx="160" cy="78" r="8" fill="currentColor" fillOpacity="0.18" /> </g> ) : null}
{kind === "telemetry" ? ( <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"> <rect x="44" y="34" width="232" height="88" rx="8" fill="currentColor" fillOpacity="0.04" opacity="0.55" /> <path d="M64 102h192" opacity="0.3" /> <path d="M68 96 102 74 134 84 172 52 210 66 250 44" opacity="0.85" /> <circle cx="172" cy="52" r="3.5" fill="currentColor" /> <circle cx="250" cy="44" r="3.5" fill="currentColor" /> </g> ) : null}
{kind === "zero-trust" ? ( <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"> <path d="M160 32 204 48v30c0 24-18 40-44 48-26-8-44-24-44-48V48l44-16Z" fill="currentColor" fillOpacity="0.07" opacity="0.8" /> <path d="m145 78 10 10 21-22" /> </g> ) : null}
{kind === "passkeys" ? ( <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"> <circle cx="132" cy="78" r="22" fill="currentColor" fillOpacity="0.08" opacity="0.8" /> <circle cx="132" cy="78" r="7" opacity="0.65" /> <path d="M154 78h56" opacity="0.85" /> <path d="M188 78v12M202 78v8" opacity="0.85" /> </g> ) : null}
{kind === "webhooks" ? ( <g stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"> <rect x="48" y="48" width="70" height="60" rx="8" fill="currentColor" fillOpacity="0.06" opacity="0.65" /> <rect x="202" y="48" width="70" height="60" rx="8" fill="currentColor" fillOpacity="0.08" opacity="0.8" /> <path d="M118 78h84" strokeDasharray="4 3" opacity="0.6" /> <rect x="142" y="64" width="36" height="28" rx="6" fill="currentColor" fillOpacity="0.12" opacity="0.9" /> <path d="M153 78h14" opacity="0.85" /> </g> ) : null}
{kind === "waf" ? ( <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round"> <rect x="62" y="82" width="24" height="34" rx="4" fill="currentColor" fillOpacity="0.08" opacity="0.6" /> <rect x="102" y="64" width="24" height="52" rx="4" fill="currentColor" fillOpacity="0.1" opacity="0.7" /> <rect x="142" y="46" width="24" height="70" rx="4" fill="currentColor" fillOpacity="0.14" opacity="0.85" /> <rect x="182" y="70" width="24" height="46" rx="4" fill="currentColor" fillOpacity="0.1" opacity="0.7" /> <rect x="222" y="56" width="24" height="60" rx="4" fill="currentColor" fillOpacity="0.08" opacity="0.6" /> <line x1="48" y1="54" x2="272" y2="54" strokeDasharray="4 4" opacity="0.55" /> </g> ) : null} </svg> );}
// ---------------------------------------------------------------------------// Styles// ---------------------------------------------------------------------------
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, display: "flex", flexDirection: "column", fontFamily: fonts.body, minHeight: "100%", width: "100%", }, container: { gap: { default: spacing._10, "@media (max-width: 640px)": spacing._8, }, marginInline: "auto", maxWidth: "75rem", paddingBlock: { default: spacing._8, "@media (max-width: 640px)": spacing._6, }, paddingInline: { default: spacing._8, "@media (max-width: 640px)": spacing._4, }, width: "100%", }, brandMark: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.border, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", color: semanticColors.fg, }, brandName: { letterSpacing: "-0.01em", }, statusLink: { fontSize: fontSizes.xs, fontWeight: fontWeights.medium, }, changelogLink: { color: semanticColors.fgMuted, fontSize: fontSizes.xs, fontWeight: fontWeights.medium, }, heroCard: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.border, borderRadius: semanticRadii.panelLg, borderStyle: "solid", borderWidth: "1px", paddingBlock: { default: spacing._10, "@media (max-width: 640px)": spacing._6, }, paddingInline: { default: spacing._10, "@media (max-width: 640px)": spacing._5, }, }, heroGrid: { gridTemplateColumns: { default: "minmax(0, 1.35fr) minmax(0, 0.9fr)", "@media (max-width: 900px)": "minmax(0, 1fr)", }, }, heroTitle: { marginBlock: 0, textWrap: "balance", }, heroSubtitle: { maxWidth: "56ch", }, searchWrap: { maxWidth: "34rem", position: "relative", width: "100%", }, searchLeadingIcon: { color: semanticColors.fgMuted, display: "inline-flex", insetInlineStart: spacing._3_5, pointerEvents: "none", position: "absolute", zIndex: 1, }, searchInput: { paddingInlineEnd: spacing._14, paddingInlineStart: spacing._10, }, searchTrailing: { insetInlineEnd: spacing._2_5, position: "absolute", zIndex: 1, }, heroActions: { paddingTop: spacing._1, }, cliPanel: { backgroundColor: semanticColors.bgPanel, borderColor: semanticColors.border, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", boxShadow: semanticShadows.xs, paddingBlock: spacing._5, paddingInline: spacing._5, }, cliCommandRow: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", paddingBlock: spacing._2, paddingInlineEnd: spacing._2, paddingInlineStart: spacing._3, }, cliCommandText: { overflowX: "auto", whiteSpace: "nowrap", }, quickStartGrid: { gridTemplateColumns: { default: "repeat(3, minmax(0, 1fr))", "@media (max-width: 860px)": "minmax(0, 1fr)", }, }, quickStartCard: { backgroundColor: semanticColors.bgPanel, borderColor: { default: semanticColors.border, ":hover": semanticColors.borderEmphasized, }, borderStyle: "solid", borderWidth: "1px", transitionDuration: durations.fast, transitionProperty: "border-color, box-shadow, background-color", }, quickStartButton: { appearance: "none", backgroundColor: "transparent", borderRadius: semanticRadii.panel, borderStyle: "none", borderWidth: 0, color: "inherit", cursor: "pointer", display: "flex", flexDirection: "column", gap: spacing._3, height: "100%", outlineColor: { default: null, ":focus-visible": semanticColors.accentFocusRing, }, outlineOffset: { default: null, ":focus-visible": "2px", }, outlineStyle: { default: "none", ":focus-visible": "solid", }, outlineWidth: { default: null, ":focus-visible": "2px", }, paddingBlock: spacing._4, paddingInline: spacing._4, textAlign: "start", width: "100%", }, fullWidth: { width: "100%", }, quickStartDesc: { lineHeight: lineHeights.sm, }, quickStartFooter: { marginTop: "auto", paddingTop: spacing._1, width: "100%", }, filterCount: { fontSize: fontSizes.xs, fontVariantNumeric: "tabular-nums", opacity: 0.75, }, sectionHeader: { marginBottom: spacing._3, }, sectionHeading: { marginBlock: 0, }, // Negative outer margin offsets each clickable guide card's 8px hover inset, // keeping card media aligned to the page grid while giving generous hover targets. guideGrid: { gridTemplateColumns: "repeat(auto-fill, minmax(260px, 1fr))", marginBlock: "-0.5rem", marginInline: "-0.5rem", }, guideCard: { appearance: "none", backgroundColor: { default: "transparent", ":hover": semanticColors.bgSubtle, }, borderRadius: semanticRadii.panel, borderStyle: "none", borderWidth: 0, color: "inherit", cursor: "pointer", display: "flex", flexDirection: "column", gap: spacing._3, outlineColor: { default: null, ":focus-visible": semanticColors.accentFocusRing, }, outlineOffset: { default: null, ":focus-visible": "2px", }, outlineStyle: { default: "none", ":focus-visible": "solid", }, outlineWidth: { default: null, ":focus-visible": "2px", }, paddingBlock: spacing._2, paddingInline: spacing._2, textAlign: "start", transitionDuration: durations.fast, transitionProperty: "background-color", width: "100%", }, previewBox: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", color: semanticColors.fg, minHeight: "9.5rem", overflowX: "hidden", overflowY: "hidden", position: "relative", width: "100%", }, diagramSvg: { display: "block", height: "9.5rem", width: "100%", }, previewBadgeSlot: { insetInlineEnd: spacing._2_5, position: "absolute", top: spacing._2_5, }, guideBody: { paddingInline: spacing._0_5, }, shrink0: { flexShrink: 0, }, guideDesc: { WebkitBoxOrient: "vertical", WebkitLineClamp: 3, display: "-webkit-box", overflowX: "hidden", overflowY: "hidden", }, emptyWrap: { backgroundColor: semanticColors.bgPanel, borderColor: semanticColors.border, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", }, footer: { paddingTop: spacing._2, }, footerLinks: { fontSize: fontSizes.xs, }, dialogHeader: { flexDirection: "column", gap: spacing._2, paddingInlineEnd: spacing._12, }, dialogTitle: { marginBlock: 0, }, dialogBody: { display: "flex", flexDirection: "column", gap: spacing._4, }, dialogPreviewFrame: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", color: semanticColors.fg, overflowX: "hidden", overflowY: "hidden", width: "100%", }, dialogOverview: { lineHeight: lineHeights.md, }, codeBlockRoot: { borderColor: semanticColors.border, borderStyle: "solid", }, codeBlockContent: { backgroundColor: semanticColors.bgMuted, borderBottomLeftRadius: radii.md, borderBottomRightRadius: radii.md, color: semanticColors.fg, }, dialogFooter: { justifyContent: "space-between", },});
// ---------------------------------------------------------------------------// Component// ---------------------------------------------------------------------------
/** * DocumentationCatalog — developer documentation hub pairing a hero banner * with instant search, quick-start cards, filterable categorized guide tracks * with schematic SVG previews, an interactive article preview dialog with * copyable code snippets, and operational status / changelog links. */export function DocumentationCatalog({ title = "Harbor Edge Developer Docs", subtitle = "Build, deploy, and observe low-latency edge workers, durable caches, and zero-trust APIs across 42 global PoPs.", version = "v3.4", tracks = DEFAULT_TRACKS, quickStarts = DEFAULT_QUICK_STARTS, onOpenGuide, palette, style,}: DocumentationCatalogProps) { const queue = useMemo(() => Toast.createToaster(), []); const searchRef = useRef<HTMLInputElement>(null);
const [query, setQuery] = useState(""); const [activeTrack, setActiveTrack] = useState<"all" | DocTrackId>("all"); const [selectedGuide, setSelectedGuide] = useState<DocGuide | null>(null); const [bookmarkedIds, setBookmarkedIds] = useState<ReadonlySet<string>>( () => new Set(["quickstart-deployment"]), ); const [copiedId, setCopiedId] = useState<string | null>(null);
const allGuides = useMemo( () => tracks.flatMap((track) => track.items), [tracks], );
const guideById = useMemo(() => { const map = new Map<string, DocGuide>(); for (const guide of allGuides) { map.set(guide.id, guide); } return map; }, [allGuides]);
const trackLabelById = useMemo(() => { const map = new Map<DocTrackId, string>(); for (const track of tracks) { map.set(track.id, track.label); } return map; }, [tracks]);
// Allow pressing "/" outside inputs to focus the docs search field. useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key !== "/" || event.metaKey || event.ctrlKey || event.altKey) { return; } const target = event.target as HTMLElement | null; if ( target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) ) { return; } event.preventDefault(); searchRef.current?.focus(); }; window.addEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown); }, []);
const normalizedQuery = query.trim().toLowerCase();
const filteredTracks = useMemo(() => { return tracks .filter((track) => activeTrack === "all" || track.id === activeTrack) .map((track) => { if (!normalizedQuery) return track; const matched = track.items.filter((item) => { const haystack = [ item.title, item.description, item.overview, item.filename, ...item.topics, track.label, ] .join(" ") .toLowerCase(); return haystack.includes(normalizedQuery); }); return { ...track, items: matched }; }) .filter((track) => track.items.length > 0); }, [tracks, activeTrack, normalizedQuery]);
const visibleGuideCount = useMemo( () => filteredTracks.reduce((sum, track) => sum + track.items.length, 0), [filteredTracks], );
const copyText = useCallback( (text: string, label: string, key: string) => { if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) { void navigator.clipboard.writeText(text).catch(() => {}); } setCopiedId(key); window.setTimeout(() => { setCopiedId((current) => (current === key ? null : current)); }, 1600); queue.success(`Copied ${label}`, { description: text.length > 56 ? `${text.slice(0, 56)}…` : text, }); }, [queue], );
const toggleBookmark = useCallback( (guide: DocGuide) => { setBookmarkedIds((prev) => { const next = new Set(prev); if (next.has(guide.id)) { next.delete(guide.id); queue.info(`Removed "${guide.title}" from saved guides`); } else { next.add(guide.id); queue.success(`Saved "${guide.title}"`, { description: "Pinned to your Harbor Edge reading list.", }); } return next; }); }, [queue], );
const handleOpenFullGuide = useCallback( (guide: DocGuide) => { onOpenGuide?.(guide); queue.info(`Opening ${guide.title}`, { description: `Demo navigation → /docs/${guide.trackId}/${guide.id}`, }); setSelectedGuide(null); }, [onOpenGuide, queue], );
const handleResetFilters = useCallback(() => { setQuery(""); setActiveTrack("all"); }, []);
const handleUtilityLink = useCallback( (event: React.MouseEvent<HTMLAnchorElement>, titleText: string, description: string) => { event.preventDefault(); queue.info(titleText, { description }); }, [queue], );
const isSelectedBookmarked = selectedGuide ? bookmarkedIds.has(selectedGuide.id) : false;
return ( <div {...stylex.props(palette, styles.root, style)}> <VStack style={styles.container}> {/* Top utility bar */} <HStack render={<header />} gap="4" justify="between" wrap="wrap"> <HStack gap="2.5"> <Square render={<span />} size="sm" style={styles.brandMark} aria-hidden="true"> <HarborMarkIcon /> </Square> <Text render={<span />} size="md" weight="semibold" style={styles.brandName}> Harbor Edge </Text> <Badge variant="subtle" size="sm"> Docs </Badge> <Code variant="subtle" size="xs"> {version} </Code> </HStack>
<HStack render={<nav aria-label="Documentation status and releases" />} gap="4" wrap="wrap" > <Link href="#status" variant="plain" style={styles.statusLink} onClick={(event) => handleUtilityLink( event, "All 42 edge PoPs operational", "Global p99 cold start: 14 ms · No incidents in the past 90 days.", ) } > <Status.Root size="sm" palette={emeraldPalette}> <Status.Indicator /> All edge regions operational </Status.Root> </Link> <Link href="#changelog" variant="plain" style={styles.changelogLink} onClick={(event) => handleUtilityLink( event, `Changelog · Runtime ${version}`, "Added native TransformStream backpressure and Ed25519 JWKS caching.", ) } > Changelog ({version}) </Link> </HStack> </HStack>
{/* Hero banner card */} <section aria-label="Documentation overview" {...stylex.props(styles.heroCard)}> <Grid gap="8" align="center" style={styles.heroGrid}> <VStack gap="4"> <HStack gap="2" wrap="wrap"> <Badge variant="surface" size="sm" palette={accentPalette}> Developer Hub · {version} </Badge> <Badge variant="outline" size="sm"> {allGuides.length} Guides </Badge> </HStack>
<Heading render={<h1 />} size="4xl" style={styles.heroTitle}> {title} </Heading> <Text variant="muted" size="md" style={styles.heroSubtitle}> {subtitle} </Text>
<HStack gap="0" style={styles.searchWrap}> <span {...stylex.props(styles.searchLeadingIcon)}> <SearchIcon /> </span> <Input ref={searchRef} size="lg" aria-label="Search Harbor Edge documentation" placeholder="Search guides, SDK APIs, CLI flags, or topics…" value={query} onValueChange={(value) => setQuery(value)} style={styles.searchInput} /> <HStack gap="1" style={styles.searchTrailing}> {query.length > 0 ? ( <IconButton variant="ghost" size="2xs" aria-label="Clear search" onClick={() => setQuery("")} > <CloseIcon /> </IconButton> ) : ( <Kbd variant="outline" size="sm"> / </Kbd> )} </HStack> </HStack>
<HStack gap="3" wrap="wrap" style={styles.heroActions}> <Button variant="solid" size="md" palette={accentPalette} onClick={() => { const first = guideById.get("quickstart-deployment") ?? allGuides[0]; if (first) setSelectedGuide(first); }} > Get started <ArrowRightIcon /> </Button> <Button variant="surface" size="md" onClick={() => queue.info(`Harbor Edge ${version} Release Notes`, { description: "Streaming backpressure, 18 ms cold starts, and WebAuthn helpers are live.", }) } > Read {version} changelog </Button> </HStack> </VStack>
<VStack gap="4" style={styles.cliPanel}> <HStack gap="2" justify="between"> <Text render={<span />} size="sm" weight="semibold"> Scaffold with Harbor CLI </Text> <Badge variant="subtle" size="xs"> TypeScript </Badge> </HStack>
<HStack gap="2" justify="between" style={styles.cliCommandRow}> <Text render={<code />} variant="mono" size="xs" style={styles.cliCommandText}> npx harbor init my-edge-app </Text> <IconButton variant="ghost" size="xs" aria-label="Copy CLI init command" onClick={() => copyText("npx harbor init my-edge-app", "CLI command", "hero-cli") } > {copiedId === "hero-cli" ? <CheckIcon /> : <CopyIcon />} </IconButton> </HStack>
<Separator />
<Grid columns="3" gap="3"> <VStack gap="0.5"> <Text render={<span />} size="sm" weight="semibold" tabular="true"> 42 PoPs </Text> <Text render={<span />} variant="muted" size="xs"> Global edge </Text> </VStack> <VStack gap="0.5"> <Text render={<span />} size="sm" weight="semibold" tabular="true"> < 18 ms </Text> <Text render={<span />} variant="muted" size="xs"> Cold start </Text> </VStack> <VStack gap="0.5"> <Text render={<span />} size="sm" weight="semibold" tabular="true"> 99.99% </Text> <Text render={<span />} variant="muted" size="xs"> SLA uptime </Text> </VStack> </Grid> </VStack> </Grid> </section>
{/* Quick-start cards */} <Section.Root aria-label="Quick-start pathways"> <Grid gap="4" style={styles.quickStartGrid}> {quickStarts.map((item) => { const targetGuide = guideById.get(item.guideId); return ( <Card.Root key={item.id} variant="outline" size="sm" style={styles.quickStartCard} > <button type="button" {...stylex.props(styles.quickStartButton)} onClick={() => { if (targetGuide) { setSelectedGuide(targetGuide); } else { copyText(item.command, item.title, item.id); } }} > <HStack gap="2" justify="between" style={styles.fullWidth}> <IconBadge variant="subtle" size="sm" palette={accentPalette}> <QuickStartIcon kind={item.icon} /> </IconBadge> <Badge variant="outline" size="xs"> {item.duration} </Badge> </HStack> <div> <Text render={<h2 />} size="sm" weight="semibold"> {item.title} </Text> <Text variant="muted" size="xs" style={styles.quickStartDesc}> {item.description} </Text> </div> <HStack gap="2" justify="between" style={styles.quickStartFooter}> <Code variant="subtle" size="xs"> {item.command} </Code> <ArrowRightIcon /> </HStack> </button> </Card.Root> ); })} </Grid> </Section.Root>
{/* Track filter bar */} <HStack gap="3" justify="between" wrap="wrap"> <HStack role="group" aria-label="Filter by documentation track" gap="2" wrap="wrap"> <Button size="sm" variant={activeTrack === "all" ? "solid" : "surface"} palette={activeTrack === "all" ? accentPalette : undefined} onClick={() => setActiveTrack("all")} > All tracks <span {...stylex.props(styles.filterCount)}>{allGuides.length}</span> </Button> {tracks.map((track) => { const selected = activeTrack === track.id; return ( <Button key={track.id} size="sm" variant={selected ? "solid" : "surface"} palette={selected ? accentPalette : undefined} onClick={() => setActiveTrack(track.id)} > {track.label} </Button> ); })} </HStack>
<HStack gap="2"> <Text render={<span />} variant="muted" size="xs"> Showing {visibleGuideCount} {visibleGuideCount === 1 ? "guide" : "guides"} </Text> {query.length > 0 || activeTrack !== "all" ? ( <Button variant="ghost" size="xs" onClick={handleResetFilters}> Reset </Button> ) : null} </HStack> </HStack>
{/* Categorized guide tracks */} <main> {filteredTracks.length === 0 ? ( <div {...stylex.props(styles.emptyWrap)}> <EmptyState.Root size="md" align="center"> <EmptyState.Indicator> <SearchIcon /> </EmptyState.Indicator> <EmptyState.Content> <EmptyState.Title> No guides matched “{query.trim()}” </EmptyState.Title> <EmptyState.Description> Try searching for a runtime primitive like “stream”, “KV”, “JWT”, or “cron”, or reset track filters. </EmptyState.Description> </EmptyState.Content> <EmptyState.Actions> <Button variant="surface" size="sm" onClick={handleResetFilters}> Clear filters </Button> </EmptyState.Actions> </EmptyState.Root> </div> ) : ( <VStack gap="10"> {filteredTracks.map((track) => ( <Section.Root key={track.id} aria-labelledby={`track-${track.id}`}> <HStack align="baseline" gap="2.5" justify="between" wrap="wrap" style={styles.sectionHeader} > <VStack gap="1"> <HStack gap="2.5"> <Heading id={`track-${track.id}`} render={<h2 />} size="xl" style={styles.sectionHeading} > {track.label} </Heading> <Badge variant="subtle" size="xs"> {track.items.length} </Badge> </HStack> <Text variant="muted" size="sm"> {track.description} </Text> </VStack> </HStack>
<Section.Body> <Grid gap="2" style={styles.guideGrid}> {track.items.map((item) => ( <button key={item.id} type="button" aria-label={`Open ${item.title} guide`} {...stylex.props(styles.guideCard)} onClick={() => setSelectedGuide(item)} > <Center style={styles.previewBox}> <GuidePreviewDiagram kind={item.diagram} /> {item.badge ? ( <span {...stylex.props(styles.previewBadgeSlot)}> <Badge variant="surface" size="xs" palette={accentPalette}> {item.badge} </Badge> </span> ) : null} </Center>
<VStack gap="1" style={styles.guideBody}> <HStack gap="2" justify="between"> <Text render={<h3 />} size="sm" weight="semibold"> {item.title} </Text> <Text render={<span />} variant="subtle" size="xs" tabular="true" style={styles.shrink0} > {item.readTime} </Text> </HStack> <Text variant="muted" size="sm" style={styles.guideDesc}> {item.description} </Text> </VStack> </button> ))} </Grid> </Section.Body> </Section.Root> ))} </VStack> )} </main>
{/* Footer status & changelog strip */} <Separator /> <HStack render={<footer />} gap="4" justify="between" wrap="wrap" style={styles.footer}> <HStack gap="3" wrap="wrap"> <Status.Root size="sm" palette={emeraldPalette}> <Status.Indicator /> Operational · 42 PoPs </Status.Root> <Text render={<span />} variant="muted" size="xs"> Harbor Runtime {version}.2 · Updated Nov 28 </Text> </HStack>
<HStack gap="4" wrap="wrap" style={styles.footerLinks}> <Link href="#system-status" variant="plain" onClick={(event) => handleUtilityLink( event, "Harbor Edge System Status", "All API gateways, KV clusters, and build pipelines are healthy.", ) } > System Status </Link> <Link href="#release-changelog" variant="plain" onClick={(event) => handleUtilityLink( event, `Changelog · ${version}.2`, "Includes lower isolate cold-start times and faster local KV snapshots.", ) } > Changelog </Link> <Link href="#cli-releases" variant="plain" onClick={(event) => handleUtilityLink( event, "Harbor CLI Releases", "Latest CLI package: @harbor-edge/cli@3.4.2 (MIT).", ) } > CLI Releases </Link> <Link href="#api-spec" variant="plain" onClick={(event) => handleUtilityLink( event, "OpenAPI 3.1 Specification", "REST control-plane schema ready for SDK code generation.", ) } > API Spec </Link> </HStack> </HStack> </VStack>
{/* Interactive article preview dialog */} <Dialog.Root open={selectedGuide !== null} onOpenChange={(open) => { if (!open) setSelectedGuide(null); }} size="lg" placement="center" > <Dialog.Backdrop /> <Dialog.Content> {selectedGuide ? ( <> <Dialog.Close render={ <IconButton variant="ghost" size="xs" aria-label="Close guide preview" /> } > <CloseIcon /> </Dialog.Close>
<Dialog.Header style={styles.dialogHeader}> <HStack gap="2" wrap="wrap"> <Badge variant="subtle" size="sm" palette={accentPalette}> {trackLabelById.get(selectedGuide.trackId) ?? "Guide"} </Badge> <Badge variant="outline" size="sm"> {selectedGuide.readTime} read </Badge> <Text render={<span />} variant="muted" size="xs"> {selectedGuide.version} · Updated {selectedGuide.updatedLabel} </Text> </HStack> <Dialog.Title style={styles.dialogTitle}> {selectedGuide.title} </Dialog.Title> <Dialog.Description>{selectedGuide.description}</Dialog.Description> </Dialog.Header>
<Dialog.Body style={styles.dialogBody}> <Center style={styles.dialogPreviewFrame}> <GuidePreviewDiagram kind={selectedGuide.diagram} /> </Center>
<Text size="sm" style={styles.dialogOverview}> {selectedGuide.overview} </Text>
<HStack gap="1.5" wrap="wrap"> {selectedGuide.topics.map((topic) => ( <Tag.Root key={topic} variant="subtle" size="sm"> <Tag.Label>{topic}</Tag.Label> </Tag.Root> ))} </HStack>
<CodeBlock.Root size="sm" style={styles.codeBlockRoot}> <CodeBlock.Header> <CodeBlock.Title>{selectedGuide.filename}</CodeBlock.Title> <CodeBlock.Control> <Button variant="ghost" size="2xs" onClick={() => copyText( selectedGuide.snippet, selectedGuide.filename, selectedGuide.id, ) } > {copiedId === selectedGuide.id ? <CheckIcon /> : <CopyIcon />} {copiedId === selectedGuide.id ? "Copied" : "Copy"} </Button> </CodeBlock.Control> </CodeBlock.Header> <CodeBlock.Content style={styles.codeBlockContent}> <CodeBlock.Code> <CodeBlock.CodeText>{selectedGuide.snippet}</CodeBlock.CodeText> </CodeBlock.Code> </CodeBlock.Content> </CodeBlock.Root> </Dialog.Body>
<Dialog.Footer style={styles.dialogFooter}> <Button variant="ghost" size="sm" onClick={() => toggleBookmark(selectedGuide)} > <BookmarkIcon filled={isSelectedBookmarked} /> {isSelectedBookmarked ? "Saved" : "Save guide"} </Button>
<HStack gap="2"> <Button variant="surface" size="sm" onClick={() => setSelectedGuide(null)} > Close </Button> <Button variant="solid" size="sm" palette={accentPalette} onClick={() => handleOpenFullGuide(selectedGuide)} > Open full guide <ArrowRightIcon /> </Button> </HStack> </Dialog.Footer> </> ) : null} </Dialog.Content> </Dialog.Root>
<Toaster toaster={queue} /> </div> );}
Inspired by the Documentation Catalog template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).