Splits the landing page into / and /ru/ so each language can rank on its own, with hreflang links between them; boot.js/main.js now do a real navigation between the two instead of toggling text in place. Adds robots.txt and sitemap.xml, JSON-LD SoftwareApplication markup, Twitter Card tags, and a proper 1200x630 og-image.png in place of the SVG favicon for social previews. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
var root = document.documentElement;
|
|
var onRuPage = location.pathname.indexOf("/ru/") === 0 || location.pathname === "/ru";
|
|
var stored = null;
|
|
var theme = null;
|
|
|
|
try {
|
|
stored = localStorage.getItem("cursorlang.lang");
|
|
theme = localStorage.getItem("cursorlang.theme");
|
|
} catch (error) {
|
|
// Storage refused: what the URL says stands
|
|
}
|
|
|
|
// A stored choice always wins, on either page.
|
|
if (stored === "ru" && !onRuPage) {
|
|
location.replace("/ru/" + location.search + location.hash);
|
|
return;
|
|
}
|
|
if (stored === "en" && onRuPage) {
|
|
location.replace("/" + location.search + location.hash);
|
|
return;
|
|
}
|
|
|
|
// No stored choice yet: send a browser set to Russian to the Russian page,
|
|
// once. Never redirect away from a page a link already pointed at — a
|
|
// shared /ru/ link, or a crawler fetching either URL directly, stands.
|
|
if (!stored && !onRuPage && (navigator.language || "").toLowerCase().indexOf("ru") === 0) {
|
|
location.replace("/ru/" + location.search + location.hash);
|
|
return;
|
|
}
|
|
|
|
var lang = onRuPage ? "ru" : "en";
|
|
root.setAttribute("data-lang", lang);
|
|
root.setAttribute("lang", lang);
|
|
|
|
if (theme === "dark" || theme === "light") {
|
|
root.setAttribute("data-theme", theme);
|
|
}
|
|
}());
|