feat(www): locale specific urls (#12508)

This commit is contained in:
Adam
2026-02-06 11:30:40 -06:00
committed by GitHub
parent 8069197329
commit 24cd84cda5
33 changed files with 279 additions and 134 deletions

View File

@@ -1,5 +1,16 @@
import { createMiddleware } from "@solidjs/start/middleware"
import { LOCALE_HEADER, cookie, fromPathname, strip } from "~/lib/language"
export default createMiddleware({
onBeforeResponse() {},
onRequest(event) {
const url = new URL(event.request.url)
const locale = fromPathname(url.pathname)
if (!locale) return
event.request.headers.set(LOCALE_HEADER, locale)
event.response.headers.append("set-cookie", cookie(locale))
url.pathname = strip(url.pathname)
event.request = new Request(url, event.request)
},
})