Skip to content

Commit 68ea328

Browse files
feat(site): link to the Console pages in the page's language (#66852)
1 parent 497569c commit 68ea328

21 files changed

Lines changed: 202 additions & 47 deletions

‎services/site/src/component/header.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ export function Header(props: { zen?: boolean; go?: boolean; hideGetStarted?: bo
155155
<a href={language.route("/data")}>{i18n.t("nav.data")}</a>
156156
</li>
157157
<li>
158-
<A href="/console/models">{i18n.t("nav.zen")}</A>
158+
<A href={language.consoleRoute("/console/models")}>{i18n.t("nav.zen")}</A>
159159
</li>
160160
<li>
161-
<A href="/console/go">{i18n.t("nav.go")}</A>
161+
<A href={language.consoleRoute("/console/go")}>{i18n.t("nav.go")}</A>
162162
</li>
163163
<li>
164-
<A href="/console/enterprise">{i18n.t("nav.enterprise")}</A>
164+
<A href={language.consoleRoute("/console/enterprise")}>{i18n.t("nav.enterprise")}</A>
165165
</li>
166166
<Show when={props.zen || props.go}>
167167
<li>
@@ -256,16 +256,16 @@ export function Header(props: { zen?: boolean; go?: boolean; hideGetStarted?: bo
256256
</li>
257257
<Show when={!props.zen}>
258258
<li>
259-
<A href="/console/models">{i18n.t("nav.zen")}</A>
259+
<A href={language.consoleRoute("/console/models")}>{i18n.t("nav.zen")}</A>
260260
</li>
261261
</Show>
262262
<Show when={!props.go}>
263263
<li>
264-
<A href="/console/go">{i18n.t("nav.go")}</A>
264+
<A href={language.consoleRoute("/console/go")}>{i18n.t("nav.go")}</A>
265265
</li>
266266
</Show>
267267
<li>
268-
<A href="/console/enterprise">{i18n.t("nav.enterprise")}</A>
268+
<A href={language.consoleRoute("/console/enterprise")}>{i18n.t("nav.enterprise")}</A>
269269
</li>
270270
<Show when={props.zen || props.go}>
271271
<li>

‎services/site/src/component/site/arcade/chrome.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export { arcadeMenu }
4949
export function ArcadeChrome(props: { settingsRows?: () => JSX.Element }) {
5050
const i18n = useI18n()
5151
const language = useLanguage()
52-
const links = createMemo(() => siteLinks(i18n.t, language.route))
52+
const links = createMemo(() => siteLinks(i18n.t, language.route, language.consoleRoute))
5353
useViewportCover()
5454
// The same items and order as the site's sidebar (site.tsx) with the current settings.
5555
const nav = createMemo(() => {

‎services/site/src/component/site/byos-options.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "./byos-options.css"
22
import { For, Show } from "solid-js"
33
import { useI18n } from "~/context/i18n"
4+
import { useLanguage } from "~/context/language"
45
import { rich } from "~/i18n/rich"
56
import { byos } from "~/lib/byos"
67
import { byosOptions } from "~/lib/byos-options"
@@ -24,11 +25,12 @@ const providers = marks.filter((provider) => !shown.has(provider.id))
2425

2526
/** Each option's lead, in place of the section's own (inside its lead paragraph). */
2627
export function ByosOptionLeads() {
28+
const language = useLanguage()
2729
const link = (text: string) => (
2830
<Rich
2931
value={linkPhrases(
3032
text,
31-
byos.planLinks.map((phrase) => ({ text: phrase, href: byos.plansHref })),
33+
byos.planLinks.map((phrase) => ({ text: phrase, href: language.consoleRoute(byos.plansHref) })),
3234
)}
3335
/>
3436
)
@@ -43,6 +45,7 @@ export function ByosOptionLeads() {
4345

4446
export function ByosOptions() {
4547
const i18n = useI18n()
48+
const language = useLanguage()
4649
const providersLink = docsUrl("/providers/")
4750
return (
4851
<div data-slot="options">
@@ -100,7 +103,7 @@ export function ByosOptions() {
100103
<For each={byosOptions.opencode}>
101104
{(item) => (
102105
<li>
103-
<a href={item.href}>{item.name}</a>
106+
<a href={language.consoleRoute(item.href)}>{item.name}</a>
104107
</li>
105108
)}
106109
</For>

‎services/site/src/component/site/links.ts‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { docsUrl } from "~/lib/docs"
44
import type { Translate } from "~/i18n"
55

66
/** The sidebar and footer links, shared by the layout and the Markdown versions of the pages. */
7-
export function siteLinks(t: Translate, route: (path: string) => string) {
7+
export function siteLinks(t: Translate, route: (path: string) => string, consoleHref = route) {
88
return {
99
// Every item the primary nav can show, in the default order (settings.ts navDefaults says which
1010
// show by default). Design mode reorders, hides and renames them (settings navConfig); the links
@@ -22,14 +22,26 @@ export function siteLinks(t: Translate, route: (path: string) => string) {
2222
{
2323
id: "console",
2424
label: t("site.nav.console"),
25-
href: "/console",
25+
href: consoleHref("/console"),
2626
demo: route("/console-demo"),
2727
arrow: true,
2828
company: true,
2929
},
30-
{ id: "models", label: t("site.nav.models"), href: "/console/models", arrow: true, company: true },
31-
{ id: "subscriptions", label: t("site.nav.subscriptions"), href: "/console/go", arrow: true, company: true },
32-
{ id: "enterprise", label: t("nav.enterprise"), href: "/console/enterprise", arrow: true, company: true },
30+
{ id: "models", label: t("site.nav.models"), href: consoleHref("/console/models"), arrow: true, company: true },
31+
{
32+
id: "subscriptions",
33+
label: t("site.nav.subscriptions"),
34+
href: consoleHref("/console/go"),
35+
arrow: true,
36+
company: true,
37+
},
38+
{
39+
id: "enterprise",
40+
label: t("nav.enterprise"),
41+
href: consoleHref("/console/enterprise"),
42+
arrow: true,
43+
company: true,
44+
},
3345
{ id: "changelog", label: t("footer.changelog"), href: route("/changelog") },
3446
// Also the GitHub mark in the top-right corner (site.tsx).
3547
{ id: "github", label: t("nav.github"), href: config.github.repoUrl, external: true, arrow: true },
@@ -86,10 +98,10 @@ export function siteLinks(t: Translate, route: (path: string) => string) {
8698
{
8799
title: "Anomaly",
88100
links: [
89-
{ label: t("site.nav.console"), href: "/console" },
90-
{ label: "OpenCode Models", href: "/console/models" },
91-
{ label: t("site.nav.subscriptions"), href: "/console/go" },
92-
{ label: t("nav.enterprise"), href: "/console/enterprise" },
101+
{ label: t("site.nav.console"), href: consoleHref("/console") },
102+
{ label: "OpenCode Models", href: consoleHref("/console/models") },
103+
{ label: t("site.nav.subscriptions"), href: consoleHref("/console/go") },
104+
{ label: t("nav.enterprise"), href: consoleHref("/console/enterprise") },
93105
{ label: t("legal.privacy"), href: route("/legal/privacy-policy") },
94106
{ label: t("legal.terms"), href: route("/legal/terms-of-service") },
95107
],

‎services/site/src/component/site/search-index.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { localize } from "~/i18n/content"
55
import { extensionsSource } from "~/i18n/content/areas/extensions"
66
import { productDetailsSource } from "~/i18n/content/areas/product-details"
77
import { productsSource } from "~/i18n/content/areas/products"
8-
import type { Locale } from "~/lib/language"
8+
import { consoleRoute, type Locale } from "~/lib/language"
99
import { brandContent, brandMarkdown } from "~/lib/brand-content"
1010
import { brandAssets } from "~/lib/media"
1111
import type { ChangelogRelease } from "~/lib/changelog"
@@ -60,7 +60,7 @@ export function buildSearchIndex(
6060
locale: Locale,
6161
dev: boolean,
6262
): SearchItem[] {
63-
const home = homeContent(t, route)
63+
const home = homeContent(t, route, (path) => consoleRoute(locale, path))
6464
const download = localize(locale, "download", downloadContent(t, route))
6565
const press = localize(locale, "press", pressContent(t, route))
6666
const brand = localize(locale, "brand", brandContent(t))
@@ -132,9 +132,17 @@ export function buildSearchIndex(
132132
}),
133133
)
134134
const external: SearchItem[] = [
135-
{ title: t("site.nav.console"), href: "/console", keywords: "models subscriptions zen go" },
136-
{ title: t("site.nav.subscriptions"), href: "/console/go", keywords: "go go plus plans pricing subscribe" },
137-
{ title: t("nav.enterprise"), href: "/console/enterprise", keywords: "sales business teams" },
135+
{ title: t("site.nav.console"), href: consoleRoute(locale, "/console"), keywords: "models subscriptions zen go" },
136+
{
137+
title: t("site.nav.subscriptions"),
138+
href: consoleRoute(locale, "/console/go"),
139+
keywords: "go go plus plans pricing subscribe",
140+
},
141+
{
142+
title: t("nav.enterprise"),
143+
href: consoleRoute(locale, "/console/enterprise"),
144+
keywords: "sales business teams",
145+
},
138146
{ title: "GitHub", href: config.github.repoUrl, keywords: "source repo code" },
139147
].map((page) => ({ id: `page:${page.href}`, group: "Pages", context: page.href, ...page }))
140148

@@ -311,7 +319,7 @@ export function buildSearchIndex(
311319

312320
/** The brand page as Markdown, as its "Copy rules for your agent" button copies it. */
313321
export function brandRules(t: Translate, route: (path: string) => string) {
314-
return markdownDocument("/brand", brandMarkdown, { t, route })
322+
return markdownDocument("/brand", brandMarkdown, { t, route, consoleRoute: route })
315323
}
316324

317325
/** Changelog entries and their versions, from the same JSON the changelog serves. */

‎services/site/src/component/site/site.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ export function Site(props: {
395395
}
396396

397397
// Follows the locale, so a client-side language switch relabels the nav and footer.
398-
const links = createMemo(() => siteLinks(i18n.t, language.route))
398+
const links = createMemo(() => siteLinks(i18n.t, language.route, language.consoleRoute))
399399
// Every known item renders, in the saved list's order (Design mode shows the hidden ones, dimmed);
400400
// the shown ones are numbered and take the number keys. The items stay the same objects while the
401401
// list changes, so a reorder moves them in place.

‎services/site/src/component/site/use-markdown.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function useMarkdownContext(data: MarkdownData) {
5454
return (): MarkdownContext => ({
5555
t: i18n.t,
5656
route: language.route,
57+
consoleRoute: language.consoleRoute,
5758
changelog: data.changelog?.(),
5859
releases: data.releases?.(),
5960
})

‎services/site/src/context/language.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
localized,
1616
pageLocale,
1717
parseLocale,
18+
consoleRoute as localeConsoleRoute,
1819
route as localeRoute,
1920
tag as localeTag,
2021
} from "~/lib/language"
@@ -81,6 +82,9 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
8182
route(pathname: string) {
8283
return localeRoute(current(), pathname)
8384
},
85+
consoleRoute(pathname: string) {
86+
return localeConsoleRoute(current(), pathname)
87+
},
8488
setLocale(next: Locale) {
8589
setCurrent(next)
8690
if (typeof document !== "object") return

‎services/site/src/lib/get-started.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import { docsUrl } from "~/lib/docs"
1717
/** The free models the site names (models.dev's opencode provider has the full, live list). */
1818
export const freeModels = ["Big Pickle", "DeepSeek V4.1 Flash Free"]
1919

20-
export function getStarted(route: (path: string) => string) {
20+
export function getStarted(route: (path: string) => string, consoleHref = route) {
2121
const links = {
2222
download: route("/product"),
2323
// The docs' list of the free models (its pricing table above mixes in the paid ones).
2424
free: route(docsUrl("/console/models/#free-models")),
2525
subs: route(docsUrl("/providers/")),
26-
go: "/console/go",
26+
go: consoleHref("/console/go"),
2727
}
2828
return {
2929
title: "Get started",
@@ -40,8 +40,8 @@ export function getStarted(route: (path: string) => string) {
4040
freeModels,
4141
subscriptions: byos.yours.items,
4242
plans: [
43-
{ name: "OpenCode Go", amount: "$10", href: "/console/go#console-go-plan-go" },
44-
{ name: "OpenCode Go Plus", amount: "$40", href: "/console/go#console-go-plan-go-plus" },
43+
{ name: "OpenCode Go", amount: "$10", href: consoleHref("/console/go#console-go-plan-go") },
44+
{ name: "OpenCode Go Plus", amount: "$40", href: consoleHref("/console/go#console-go-plan-go-plus") },
4545
],
4646
steps: [
4747
{ title: "Download", line: "Desktop, terminal or mobile." },

‎services/site/src/lib/home-content.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function linkPhrases(text: string, links: readonly { text: string; href:
3131
* The home page copy, shared by the page and its Markdown version so the two never drift.
3232
* `route` localizes a site path.
3333
*/
34-
export function homeContent(t: Translate, route: (path: string) => string) {
34+
export function homeContent(t: Translate, route: (path: string) => string, consoleHref = route) {
3535
const docs = (path: string) => `https://opencode.ai${docsUrl(path)}`
3636
return {
3737
title: t("home.title"),
@@ -163,10 +163,10 @@ export function homeContent(t: Translate, route: (path: string) => string) {
163163
title: t("site.nav.console"),
164164
headline: t("home.console.headline"),
165165
body: t("home.console.body"),
166-
cta: { text: t("home.console.cta"), href: "/console" },
166+
cta: { text: t("home.console.cta"), href: consoleHref("/console") },
167167
// The slim option: one line that names the Console, and a second action.
168168
slimHeadline: t("home.console.slimHeadline"),
169-
sales: { text: t("home.console.sales"), href: "/console/enterprise" },
169+
sales: { text: t("home.console.sales"), href: consoleHref("/console/enterprise") },
170170
},
171171
}
172172
}

0 commit comments

Comments
 (0)