Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Support localised redirects

Blue Mouse94df074f77a8
diff --git a/web/app/routes/demo.tsx b/web/app/routes/demo.tsx
index 8903d7362..3e3cfb305 100644
--- a/web/app/routes/demo.tsx
+++ b/web/app/routes/demo.tsx
@@ -1,10 +1,20 @@
-import { redirect } from 'react-router'
+import { redirect, type LoaderFunctionArgs } from 'react-router'
import { SitemapFunction } from 'remix-sitemap'
+import {
+ getLangFromPath,
+ LIVE_DEMO_URL,
+ localisePath,
+ MAIN_URL,
+} from '~/lib/constants'
+
export const sitemap: SitemapFunction = () => ({
exclude: true,
})
-export const loader = async () => {
- return redirect('https://swetrix.com/projects/STEzHcB1rALV')
+export const loader = async ({ request }: LoaderFunctionArgs) => {
+ const lang = getLangFromPath(new URL(request.url).pathname)
+ const demoPath = lang ? localisePath(LIVE_DEMO_URL, lang) : LIVE_DEMO_URL
+
+ return redirect(`${MAIN_URL}${demoPath}`)
}