Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 51 additions & 3 deletions frontend/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const copyrightByLocale: Record<string, string> = {
"zh-CN": `版权所有 © ${currentYear} open.mp。基于Docusaurus构建。`,
tr: `Telif Hakkı © ${currentYear} open.mp. Docusaurus ile yapıldı.`,
fa: `حق نشر © ${currentYear} open.mp. ساخته شده با Docusaurus.`,

};

const config: Config = {
Expand Down Expand Up @@ -236,6 +235,55 @@ const config: Config = {
],
],

headTags: [
{
tagName: "script",
attributes: {},
innerHTML: `
(function() {
var locales = ["en","es","ru","ar","bs","de","fil","fr","fa","hu","id","it","nl","pl","pt-BR","ro","sl","sr","ta","th","tr","uk","vi","zh-CN","zh-TW"];
var path = window.location.pathname;
var firstSegment = path.split("/")[1];

if(locales.indexOf(firstSegment) !== -1) {
localStorage.setItem("omp-locale", firstSegment);
return;
}

var saved = localStorage.getItem("omp-locale");

if(saved && saved !== "en") {
window.location.href = "/" + saved + path + window.location.search + window.location.hash;
return;
}

if(saved === "en") return;

var navLang = (navigator.language || navigator.userLanguage || "en").toLowerCase();

var map = {
"pt": "pt-BR", "pt-br": "pt-BR",
"zh": "zh-CN", "zh-cn": "zh-CN", "zh-tw": "zh-TW",
"zh-hans": "zh-CN", "zh-hant": "zh-TW"
};

var target = map[navLang] || navLang;

if(locales.indexOf(target) === -1 && navLang.indexOf("-") !== -1) {
target = navLang.split("-")[0];
}

if(locales.indexOf(target) !== -1 && target !== "en") {
localStorage.setItem("omp-locale", target);
window.location.href = "/" + target + path + window.location.search + window.location.hash;
} else {
localStorage.setItem("omp-locale", "en");
}
})();
`,
},
],

themeConfig: {
// Replace with your project's social card
image: "images/assets/wordmark-coloured-bg.png",
Expand Down Expand Up @@ -367,10 +415,10 @@ const config: Config = {
// Optional: see doc section below
contextualSearch: true,

// Optional: path for search page that enabled by default (`false` to disable it)
// Optional: path for search page that enabled by default (\`false\` to disable it)
searchPagePath: "search",

// Optional: whether the insights feature is enabled or not on Docsearch (`false` by default)
// Optional: whether the insights feature is enabled or not on Docsearch (\`false\` by default)
insights: false,
},
colorMode: {
Expand Down