mirror of
https://github.com/longbridge/developers.git
synced 2026-09-19 03:34:09 +08:00
7571ffcc04
## Merge Verdict **[APPROVE]** — Small, mechanical extension of the existing region rewrite to cover a third root domain (`mcp.longbridge.com`). > 3 files · +8 / -1 · `region.config.ts` `docs/.vitepress/` --- ## Summary - `region.config.ts`: `RegionConfig` interface gains a new required field `mcpHostname`; CN region sets it to `https://mcp.longbridge.cn`. - `docs/.vitepress/region-utils.ts`: `buildRegionUrlReplacements()` emits a third pair of rules (URL + bare-text) for the MCP hostname — same shape as the existing `siteHostname` / `apiBaseUrl` blocks. - `docs/.vitepress/config.mts`: `MCP_TOOLS_URL` (used by the `fetch-mcp-tools` build-time plugin) now resolves to `${regionCfg?.mcpHostname || 'https://mcp.longbridge.com'}/mcp/tools.json` — CN builds source the tool catalogue from the regional endpoint instead of `.com`. --- ## Risk Analysis | Risk | Level | Mitigation | |------|-------|-----------| | `mcp.longbridge.cn/mcp/tools.json` endpoint not yet live | 🟡 | Reviewer to confirm before merge — `fetch-mcp-tools` will hard-fail the CN build if the URL 404s | | Global build (`build:release`) regression | ✅ | Verified: with no `VITE_REGION`, `regionCfg` is undefined → helper returns `[]` for MCP rules; `MCP_TOOLS_URL` falls back to `mcp.longbridge.com`; `mcp.html` keeps 7 `.com` + 1 `.cn` (original "China mainland" section) identical to source | | Order-dependent rewriting between `mcp` / `open` / `openapi` | ✅ | All three hostnames are mutually non-substring (different 5th char or different prefix), so the three protocol-prefixed + three bare-text rules are independent regardless of order | | Mainland users on global `.cn` site getting wrong fallback | ✅ | This PR only adds a CN-only rule; nothing about the global path changes | --- ## Design Decisions - **Add `mcpHostname` to `RegionConfig` rather than hardcoding inside the helper** — keeps the regional URL list in one declarative file (`region.config.ts`) instead of scattering string constants across `region-utils.ts`. Matches the pattern already set by `siteHostname` / `apiBaseUrl`. - **Switch the build-time fetch source, not just the displayed URL** — chosen so the CN build's `mcp-tools.json` actually reflects the catalogue served by the CN MCP endpoint (potentially region-specific tools), instead of CN docs displaying `.cn` while embedded data was scraped from `.com`. - **Field is required, not optional** — every region must declare its MCP hostname explicitly; prevents silent fallback to `.com` when a new region is added. --- ## Code Notes 1. **[Needs review]** Confirm `https://mcp.longbridge.cn/mcp/tools.json` is live and returns the same JSON shape as the global endpoint before merge. If not yet deployed, the CN build will fail at `fetch-mcp-tools` `buildStart` with an HTTP error. --- ## Verification - ✅ `bun run build:cn` succeeds; `rg -l '(open|openapi|mcp)\.longbridge\.com' docs/.vitepress/dist` → zero residual `.com` across HTML / MD / JS / install scripts / `mcp-tools.json`. - ✅ `bun run build:release` succeeds; `dist/docs/mcp.md` per-file domain distribution (1× `mcp.longbridge.cn` + 7× `mcp.longbridge.com`) matches source 1:1. - ✅ Source `install.ps1` is byte-identical to global build output (no accidental rewrite). Co-authored-by: 袁昌瑞 <changrui.yuan@longbridge-inc.com>
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
export interface RegionSectionExclusion {
|
|
/** Glob pattern matching page paths */
|
|
page: string
|
|
/** Heading texts to exclude — removes heading + content until next same-level heading */
|
|
headings: string[]
|
|
}
|
|
|
|
export interface RegionConfig {
|
|
/** API base URL for this region */
|
|
apiBaseUrl: string
|
|
/** Portal gateway base URL for this region */
|
|
portalGatewayBaseUrl: string
|
|
/** Site hostname for canonical URLs, sitemap, etc. */
|
|
siteHostname: string
|
|
/** MCP server hostname for this region (used both for build-time tools fetch and runtime URLs shown to users) */
|
|
mcpHostname: string
|
|
/**
|
|
* Page whitelist — only pages matching these glob patterns are included.
|
|
* Uses `**` prefix to match across all locale directories (en, zh-CN, zh-HK).
|
|
* Pages not matching any pattern are excluded from the build.
|
|
*/
|
|
includePages: string[]
|
|
/** Nav items to exclude — matches against the link path (e.g. '/', '/docs/api', '/sdk') */
|
|
excludeNavLinks: string[]
|
|
/** In-page section exclusions (applied within whitelisted pages) */
|
|
excludeSections: RegionSectionExclusion[]
|
|
}
|
|
|
|
export const regionConfig: Record<string, RegionConfig> = {
|
|
cn: {
|
|
apiBaseUrl: 'https://openapi.longbridge.cn',
|
|
portalGatewayBaseUrl: 'https://m.lbkrs.com',
|
|
siteHostname: 'https://open.longbridge.cn',
|
|
mcpHostname: 'https://mcp.longbridge.cn',
|
|
|
|
excludeNavLinks: ['/', '/docs/api', '/sdk'],
|
|
|
|
includePages: [
|
|
// Only CLI under /docs/
|
|
'**/docs/cli.md',
|
|
'**/docs/cli/index.md',
|
|
'**/docs/cli/install.md',
|
|
'**/docs/cli/release-notes.md',
|
|
|
|
// MCP
|
|
'**/docs/mcp.md',
|
|
|
|
// Agent Auth Code
|
|
'**/docs/agent-auth.md',
|
|
|
|
// AI Skills
|
|
'**/skill/**',
|
|
],
|
|
|
|
excludeSections: [
|
|
// Example: remove US stock trading sections from getting-started
|
|
// {
|
|
// page: '**/docs/getting-started.md',
|
|
// headings: ['US Stock Trading', '美股交易', '美股交易'],
|
|
// },
|
|
],
|
|
},
|
|
}
|