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!

added alternate links

Blue Mouse253ab3a32c16
diff --git a/app/entry.server.tsx b/app/entry.server.tsx
index 59d47802e..3fb6712ed 100644
--- a/app/entry.server.tsx
+++ b/app/entry.server.tsx
@@ -10,6 +10,7 @@ import isbot from 'isbot'
import { renderToPipeableStream } from 'react-dom/server'
import { createSitemapGenerator } from 'remix-sitemap'
+import { MAIN_URL } from './redux/constants'
import i18next from './i18next.server'
import i18n, { detectLanguage } from './i18n'
@@ -17,7 +18,7 @@ const ABORT_DELAY = 5_000
// TODO: Exclude /project/* endpoints from sitemap
const { isSitemapUrl, sitemap } = createSitemapGenerator({
- siteUrl: 'https://swetrix.com',
+ siteUrl: MAIN_URL,
autoLastmod: false,
priority: 0.8
})
diff --git a/app/redux/constants/index.ts b/app/redux/constants/index.ts
index a832155a1..264ffee48 100644
--- a/app/redux/constants/index.ts
+++ b/app/redux/constants/index.ts
@@ -198,6 +198,7 @@ export const TWITTER_USERNAME: string = '@swetrix'
export const DISCORD_URL: string = 'https://discord.gg/tVxGxU3s4B'
export const STATUSPAGE_URL: string = 'https://stats.uptimerobot.com/33rvmiXXEz'
export const BLOG_URL: string = 'https://blog.swetrix.com'
+export const MAIN_URL: string = 'https://swetrix.com'
export const UTM_GENERATOR_URL: string = 'https://url.swetrix.com'
export const LIVE_DEMO_URL: string = '/projects/STEzHcB1rALV'
export const MARKETPLACE_URL: string = 'https://marketplace.swetrix.com'
diff --git a/app/root.tsx b/app/root.tsx
index aa5790e0f..90111f395 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -9,7 +9,9 @@ import {
ScrollRestoration,
} from '@remix-run/react'
import { store } from 'redux/store'
+import { MAIN_URL, whitelist } from 'redux/constants'
import { Provider } from 'react-redux'
+import _map from 'lodash/map'
// @ts-ignore
import { transitions, positions, Provider as AlertProvider } from '@blaumaus/react-alert'
import BillboardCss from 'billboard.js/dist/billboard.min.css'
@@ -64,9 +66,10 @@ const removeObsoleteAuthTokens = () => {
removeObsoleteAuthTokens()
export async function loader({ request }: LoaderArgs) {
+ const { url } = request
const locale = detectLanguage(request)
- return json({ locale })
+ return json({ locale, url })
}
export const handle = {
@@ -74,9 +77,15 @@ export const handle = {
}
export default function App() {
- const { locale } = useLoaderData<typeof loader>()
+ const { locale, url } = useLoaderData<typeof loader>()
const { i18n } = useTranslation()
+ const alternateLinks = _map(whitelist, (locale) => ({
+ rel: 'alternate',
+ hrefLang: locale,
+ href: `${url}?lng=${locale}`,
+ }))
+
useChangeLanguage(locale)
return (
@@ -86,6 +95,9 @@ export default function App() {
<meta name='viewport' content='width=device-width,initial-scale=1' />
<Meta />
<Links />
+ {_map(alternateLinks, (link) => (
+ <link key={link.hrefLang} {...link} />
+ ))}
<link rel='preload' href={`/locales/${locale}.json`} as='fetch' type='application/json' crossOrigin='anonymous' />
</head>
<body>