Repository navigation
fix(api-reference): de-duplicate API page titles and descriptions - #1335
Merged
Merged
Conversation
- WS push depth/trades/candlesticks: add "Subscription" so they no longer share titles with the pull commands - fund_positions: zh title 账户基金持仓, distinct from fund_holdings - short_positions_hk/us, short_trades_hk/us: describe each endpoint's own market Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
twosugar
pushed a commit
that referenced
this pull request
Nov 19, 2026
…scription, add hreflang (#1337) ## Summary Each API Reference page (`/docs/api/<id>`) has the same H1, the same meta description and a title that only differs in the suffix from the docs page for the same endpoint (e.g. `/docs/market/top-movers`). Google Search Console shows that for 5 English pairs only one page of each pair is indexed and the other is "Crawled - currently not indexed". API pages also output no hreflang at all. Both pages should stay (the docs page covers CLI / SDK usage, the API page the HTTP request and Try it), so this PR only changes the `<head>` of API pages: | Change | File | Effect | |---|---|---| | Title and description carry the HTTP method and path; WebSocket commands use `WebSocket cmd N` | `packages/api-reference/src/openapi-markdown.ts` (`apiPageMeta()`) | `Top Movers · API Reference` → `Top Movers (POST /v1/quote/market/stock-events) · API Reference`; description becomes `POST /v1/quote/market/stock-events — Get stocks whose…`. Same 160-char truncation as before, the prefix is always kept. | | API page URLs added to the published URL set | `src/lib/published-urls.ts`, new `src/lib/api-page-urls.ts` | `BaseLayout` already emits hreflang via `buildSeoLinks()`, but only for URLs in `getPublishedUrls()`, which listed the docs collection only. API pages (161 × 3 locales) now get `en` / `zh-Hans` / `zh-Hant` / `x-default`, the same output as docs pages. No layout change. | | Tests | `packages/api-reference/src/api-page-meta.test.ts`, `src/lib/api-page-urls.test.ts` | label in every title/description, ≤160 chars, no duplicates among API pages per locale; three-locale hreflang for an API page. | Not in this PR (optional, your call): the H1 (`ep-title` in `ApiReference.tsx`) is still the bare summary, e.g. `Top Movers`, same as the docs page H1. Adding the method/path there would change what users see on the page, so I left it out. ## Verification (before merge) - Duplicate check with `apiPageMeta` (same method as #1335), 483 API pages vs 866 docs pages, same locale: | | before | after | |---|---|---| | duplicate titles among API pages | 0 | 0 | | duplicate descriptions among API pages | 0 | 0 | | API page title (without suffix) = docs page title | 347 | 0 | | API page description = docs page description | 317 | 0 | - `astro dev`, `<head>` of the 6 pairs below: all 200, title and description differ within each pair, canonical self-referencing, each API page has 4 hreflang links pointing to its own en / zh-CN / zh-HK URLs + x-default (also checked `/zh-CN/docs/api/top_movers`). - `vitest run`: 72/72 passed (8 files). `bun test` in `packages/api-reference`: 20/20. - `oxlint` on the changed files: clean. `tsc --noEmit`: no errors in the changed files (the remaining errors are the existing `astro:content` implicit-any ones, same as `main`). `prettier -c` reports only the existing long lines in `openapi-markdown.ts`. - No build was run, per `CLAUDE.md`. ## First-screen impact Only `<head>` text changes: longer title/description and 4 more `<link rel="alternate">` tags on API pages (about 0.35 KB of HTML). No new requests, no script or data changes; docs pages are unchanged. ## Post-deploy check Request each pair and compare `<title>`, `meta description`, hreflang: | Docs page | API page | |---|---| | `/docs/account/dca/update-dca` | `/docs/api/dca_update` | | `/docs/account/dca/calc-date` | `/docs/api/dca_calc_date` | | `/docs/market/top-movers` | `/docs/api/top_movers` | | `/docs/content/topics/topic-detail` | `/docs/api/topic_detail` | | `/docs/quote/pull/intraday` | `/docs/api/ws-intraday` | | `/zh-HK/docs/market/top-movers` | `/zh-HK/docs/api/top_movers` | Expected: title and description differ within each pair; API page title contains `(METHOD /path)` or `(WebSocket cmd N)`; API page has `hreflang` `en`, `zh-Hans`, `zh-Hant`, `x-default` pointing to `/docs/api/<id>`, `/zh-CN/docs/api/<id>`, `/zh-HK/docs/api/<id>`. Sample: `curl -s https://open.longbridge.com/docs/api/top_movers | grep -o '<title>[^<]*'` → `<title>Top Movers (POST /v1/quote/market/stock-events) · API Reference`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: chiba <zhiqiang.ni@longbridge-inc.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge Verdict
[APPROVE]
Summary
Several API Reference pages shared the same
<title>or meta description, which search engines treat as duplicate pages and which also misdescribed some endpoints. This PR fixes the copy inopenapi.yamlonly:ws-push-depth/ws-push-trade/ws-push-candlestick(en)Depth/Trades/Candlesticks, same as the pull commandsDepth Subscription/Trades Subscription/Candlesticks Subscriptionws-push-candlestick(zh-CN / zh-HK)K 线/K 線, same as pull实时 K 线订阅/K 線訂閱, matching the other push commands (实时盘口订阅/盤口訂閱)fund_positions(zh-CN / zh-HK)基金持仓/基金持倉, same asfund_holdings账户基金持仓/賬戶基金持倉short_positions_hk/short_positions_us(3 locales)short_trades_hk/short_trades_us(3 locales)Update cadences (daily / bi-monthly / each trading day / bi-weekly) are carried over unchanged from the original text.
Risk Analysis
… SubscriptionthereDesign Decisions
Subscriptionsuffix rather than renaming the pull side, so existing pull page titles stay stable.Code Concerns
[FYI]
symbolparameter text on the four short-selling endpoints still mentions both markets (openapi.yaml,x-parametersofshort_positions_hk/us,short_trades_hk/us): it still reads "e.g.TSLA.USor700.HK" on each market-specific endpoint. Out of scope for this copy fix; can be aligned in a follow-up.Verification
Conclusion basis: Verified
apiPageMeta(the same function the pages use): 13 duplicate groups before, 0 after.bun testinpackages/api-reference: 10 pass, 0 fail.🤖 Generated with Claude Code