mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-10 00:38:31 +00:00
fix(stats): strip locale prefixes from data routes
This commit is contained in:
parent
db7c28b3ee
commit
69f3b633b8
1 changed files with 29 additions and 0 deletions
|
|
@ -4,6 +4,34 @@ import { FileRoutes } from "@solidjs/start/router"
|
|||
import { Suspense } from "solid-js"
|
||||
import "./app.css"
|
||||
|
||||
const localePrefixes = new Set([
|
||||
"ar",
|
||||
"br",
|
||||
"da",
|
||||
"de",
|
||||
"es",
|
||||
"fr",
|
||||
"it",
|
||||
"ja",
|
||||
"ko",
|
||||
"no",
|
||||
"pl",
|
||||
"ru",
|
||||
"th",
|
||||
"tr",
|
||||
"uk",
|
||||
"zh",
|
||||
"zht",
|
||||
])
|
||||
|
||||
function stripLocaleDataPrefix(pathname: string) {
|
||||
const value = pathname.startsWith("/") ? pathname : `/${pathname}`
|
||||
const segments = value.split("/")
|
||||
if (segments[2] !== "data") return value
|
||||
if (!localePrefixes.has(segments[1] ?? "")) return value
|
||||
return value.slice((segments[1]?.length ?? 0) + 1) || "/"
|
||||
}
|
||||
|
||||
function AppMeta() {
|
||||
return (
|
||||
<>
|
||||
|
|
@ -21,6 +49,7 @@ export default function App() {
|
|||
<Router
|
||||
base={import.meta.env.BASE_URL.replace(/\/$/, "")}
|
||||
explicitLinks={true}
|
||||
transformUrl={stripLocaleDataPrefix}
|
||||
root={(props) => (
|
||||
<MetaProvider>
|
||||
<AppMeta />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue