Skip to content
Open
Show file tree
Hide file tree
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
59 changes: 42 additions & 17 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,41 @@ We welcome contributions to our documentation! Whether you're fixing a typo or a

To preview your changes locally:

1. **Navigate to the frontend directory:**
```bash
cd frontend
```
2. **Install dependencies:**
```bash
npm install
```
3. **Start the development server:**
```bash
npm start
```
The site will be available at `http://localhost:3000`. Most changes to Markdown files will live-reload in the browser.
1. **Navigate to the frontend directory:**

```bash
cd frontend
```

2. **Install dependencies:**

```bash
npm install
```

3. **Start the development server:**

```bash
npm start
```

The site will be available at `http://localhost:3000`. Most changes to Markdown files will live-reload in the browser.

#### Choosing a locale

```bash
npm start -- --locale pt-BR # http://localhost:3000/pt-BR/
npm start -- --locale zh-CN # http://localhost:3000/zh-CN/
```

`start` accepts a **single** locale — a second `--locale` is silently ignored (the last one wins) — so run one dev server per language on different ports.

### Adding or Editing Pages

- To **edit** an existing page, find the corresponding `.md` file in `docs/` and make your changes.
- To **add** a new page, create a new `.md` file in the appropriate subdirectory of `docs/`.
- Remember to update the **metadata** (front matter) at the top of the file:

```markdown
---
title: Page Title
Expand All @@ -58,29 +74,38 @@ npm i
### Local Development

```bash
npm start
npm start # default locale
npm start -- --locale pt-BR # specific locale
```

### Build

```bash
npm run build
npm run build # all locales
npm run build -- --locale pt-BR # one locale
npm run build -- --locale en --locale pt-BR --locale zh-CN # several locales
```

This command generates static content into the `build` directory.

### Local Preview

```bash
npm run serve
```

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
$ USE_SSH=true npm run deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
$ GIT_USER=<Your GitHub username> npm run deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
53 changes: 29 additions & 24 deletions frontend/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,6 @@ const config: Config = {

staticDirectories: ["public"],

plugins: [
async function serverRoutesPlugin(context, options) {
return {
name: "server-routes-plugin",
async contentLoaded({ actions }) {
const { addRoute } = actions;
const { i18n: { locales, defaultLocale } } = context;

// Add the dynamic server detail route.
locales.forEach((locale) => {
const prefix = locale === defaultLocale ? '' : `/${locale}`;
addRoute({
path: `${prefix}/servers/`,
component: "@site/src/pages/servers/index",
exact: false,
});
})
},
};
},
],

presets: [
[
"classic",
Expand Down Expand Up @@ -244,7 +222,34 @@ const config: Config = {
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];


var pageLocale = document.documentElement.getAttribute("lang") || "en";
var lastSegment = path.split("/").pop();
var is404Page = lastSegment === "404" || lastSegment === "404.html";

var localePrefix = locales.indexOf(firstSegment) !== -1 ? "/" + firstSegment : "";
var rest = path.slice(localePrefix.length);
var serversPrefix = "/servers/";

if(rest.indexOf(serversPrefix) === 0 && rest.length > serversPrefix.length) {
var address = rest.slice(serversPrefix.length);
if(address.charAt(address.length - 1) === "/") address = address.slice(0, -1);
try { address = decodeURIComponent(address); } catch (e) {}
window.location.replace(localePrefix + "/servers?ip=" + encodeURIComponent(address));
return;
}

function redirectLocale404() {
if(is404Page || firstSegment === pageLocale || locales.indexOf(firstSegment) === -1) return;
if(!document.querySelector("meta[name=omp-not-found]")) return;

localStorage.setItem("omp-locale", firstSegment);
window.location.replace("/" + firstSegment + "/404");
}

redirectLocale404();
document.addEventListener("DOMContentLoaded", redirectLocale404);

if(locales.indexOf(firstSegment) !== -1) {
localStorage.setItem("omp-locale", firstSegment);
return;
Expand Down Expand Up @@ -272,7 +277,7 @@ const config: Config = {
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;
Expand Down
6 changes: 6 additions & 0 deletions frontend/i18n/fa/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@
"serverInfo.backToServers": {
"message": "→ بازگشت به سرورها"
},
"serverInfo.backToPartners": {
"message": "← بازگشت به سرورهای شریک"
},
"serverInfo.quickJoin": {
"message": "ورود سریع"
},
Expand All @@ -283,6 +286,9 @@
"serverInfo.lastUpdated": {
"message": "{time} پیش به‌روزرسانی شده"
},
"serverInfo.notFound": {
"message": "این سرور پیدا نشد. ممکن است آفلاین باشد یا دیگر در فهرست نباشد."
},
"theme.footer.title.Documentations": {
"message": "مستندات"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/i18n/id/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
"serverInfo.backToServers": {
"message": "← Kembali ke Server"
},
"serverInfo.backToPartners": {
"message": "← Kembali ke Server Mitra"
},
"serverInfo.quickJoin": {
"message": "Bergabung Cepat"
},
Expand All @@ -289,6 +292,9 @@
"serverInfo.lastUpdated": {
"message": "Diperbarui {time} yang lalu"
},
"serverInfo.notFound": {
"message": "Server ini tidak ditemukan. Mungkin server sedang offline atau tidak lagi terdaftar."
},
"downloads.server.pageTitle": {
"message": "Server open.mp"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/i18n/pt-BR/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
"serverInfo.backToServers": {
"message": "← Voltar aos Servidores"
},
"serverInfo.backToPartners": {
"message": "← Voltar aos Servidores Parceiros"
},
"serverInfo.quickJoin": {
"message": "Entrar Rapidamente"
},
Expand All @@ -296,6 +299,9 @@
"serverInfo.lastUpdated": {
"message": "Atualizado há {time}"
},
"serverInfo.notFound": {
"message": "Este servidor não foi encontrado. Ele pode estar offline ou não estar mais na lista."
},
"downloads.server.pageTitle": {
"message": "Servidor open.mp"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/i18n/th/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
"serverInfo.backToServers": {
"message": "← กลับไปที่เซิร์ฟเวอร์"
},
"serverInfo.backToPartners": {
"message": "← กลับไปที่เซิร์ฟเวอร์พันธมิตร"
},
"serverInfo.quickJoin": {
"message": "เข้าร่วมอย่างรวดเร็ว"
},
Expand All @@ -289,6 +292,9 @@
"serverInfo.lastUpdated": {
"message": "อัปเดตเมื่อ {time} ที่แล้ว"
},
"serverInfo.notFound": {
"message": "ไม่พบเซิร์ฟเวอร์นี้ อาจออฟไลน์อยู่หรือถูกนำออกจากรายการแล้ว"
},
"downloads.server.pageTitle": {
"message": "เซิร์ฟเวอร์ open.mp"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/i18n/tr/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@
"serverInfo.backToServers": {
"message": "← Sunuculara Geri Dön"
},
"serverInfo.backToPartners": {
"message": "← İş Ortağı Sunuculara Dön"
},
"serverInfo.quickJoin": {
"message": "Hızlı Katıl"
},
Expand All @@ -283,6 +286,9 @@
"serverInfo.lastUpdated": {
"message": "{time} önce güncellendi"
},
"serverInfo.notFound": {
"message": "Bu sunucu bulunamadı. Çevrimdışı olabilir veya artık listelenmiyor olabilir."
},
"theme.footer.title.Documentations": {
"message": "Dokümantasyon"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/i18n/uk/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@
"serverInfo.backToServers": {
"message": "← Назад до серверів"
},
"serverInfo.backToPartners": {
"message": "← Назад до серверів-партнерів"
},
"serverInfo.quickJoin": {
"message": "Швидкий вхід"
},
Expand All @@ -283,6 +286,9 @@
"serverInfo.lastUpdated": {
"message": "Оновлено {time} тому"
},
"serverInfo.notFound": {
"message": "Сервер не знайдено. Можливо, він офлайн або його більше немає у списку."
},
"theme.footer.title.Documentations": {
"message": "Документація"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/i18n/zh-CN/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
"serverInfo.backToServers": {
"message": "← 返回服务器列表"
},
"serverInfo.backToPartners": {
"message": "← 返回合作伙伴服务器"
},
"serverInfo.quickJoin": {
"message": "快速加入"
},
Expand All @@ -296,6 +299,9 @@
"serverInfo.lastUpdated": {
"message": "{time}前更新"
},
"serverInfo.notFound": {
"message": "找不到该服务器,它可能已离线或不再列出。"
},
"downloads.server.pageTitle": {
"message": "open.mp 服务器"
},
Expand Down
Loading
Loading