mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2026-08-27 12:29:39 +00:00
fix href reloc
This commit is contained in:
@@ -131,7 +131,19 @@ metadata.description ||= (t({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lang && lang !== defaultLocale) {
|
if (lang && lang !== defaultLocale) {
|
||||||
location.href = `${baseUrl + lang + location.pathname + (location.hash || location.search || '')}`.replace(/\/$/, '');
|
// Localized URLs can differ from prefixed paths (blog post slugs carry a
|
||||||
|
// language suffix), so prefer the hreflang alternate rendered above.
|
||||||
|
let target;
|
||||||
|
document.querySelectorAll('link[rel="alternate"][hreflang]').forEach((link) => {
|
||||||
|
if (link.getAttribute('hreflang').toLowerCase() === lang) {
|
||||||
|
target = link.getAttribute('href');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (target) {
|
||||||
|
location.href = target + (location.hash || location.search || '');
|
||||||
|
} else {
|
||||||
|
location.href = `${baseUrl + lang + location.pathname + (location.hash || location.search || '')}`.replace(/\/$/, '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script> }
|
</script> }
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user