mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-03 06:50:26 +00:00
feat(www): locale specific urls (#12508)
This commit is contained in:
parent
8069197329
commit
24cd84cda5
33 changed files with 279 additions and 134 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type { APIEvent } from "@solidjs/start/server"
|
||||
import { localeFromCookieHeader, tag } from "~/lib/language"
|
||||
import { LOCALE_HEADER, localeFromCookieHeader, parseLocale, tag } from "~/lib/language"
|
||||
|
||||
async function handler(evt: APIEvent) {
|
||||
const req = evt.request.clone()
|
||||
|
|
@ -7,7 +7,7 @@ async function handler(evt: APIEvent) {
|
|||
const targetUrl = `https://docs.opencode.ai${url.pathname}${url.search}`
|
||||
|
||||
const headers = new Headers(req.headers)
|
||||
const locale = localeFromCookieHeader(req.headers.get("cookie"))
|
||||
const locale = parseLocale(req.headers.get(LOCALE_HEADER)) ?? localeFromCookieHeader(req.headers.get("cookie"))
|
||||
if (locale) headers.set("accept-language", tag(locale))
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue