Skip to content

Commit 1fb0a6a

Browse files
committed
update
1 parent 3d5d71b commit 1fb0a6a

9 files changed

Lines changed: 48 additions & 8 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ jobs:
2525
-v "${{ github.workspace }}:/srv/jekyll" \
2626
-e JEKYLL_ENV=production \
2727
jekyll/jekyll:4.2.2@sha256:400b8d1569f118bca8a3a09a25f32803b00a55d1ea241feaf5f904d66ca9c625 \
28-
sh -c "jekyll build --trace && mkdir -p _site/en/css _site/ru/css && cp css/*.css _site/en/css/ && cp css/*.css _site/ru/css/"
28+
sh -c "jekyll build --trace && \
29+
mkdir -p _site/en/css _site/ru/css && \
30+
cp css/*.css _site/en/css/ && \
31+
cp css/*.css _site/ru/css/ && \
32+
find _site/en -name '*.html' -exec sed -i 's|href=\"/en/|href=\"/|g' {} \; && \
33+
find _site/en -name '*.html' -exec sed -i 's|src=\"/en/|src=\"/|g' {} \; && \
34+
find _site/ru -name '*.html' -exec sed -i 's|href=\"/ru/|href=\"/|g' {} \; && \
35+
find _site/ru -name '*.html' -exec sed -i 's|src=\"/ru/|src=\"/|g' {} \;"
2936
3037
- name: Upload site artifact
3138
uses: actions/upload-artifact@v6

CNAME

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
docs.gameap.ru
2-
docs.gameap.com
1+
docs.gameap.com

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ WORKDIR /site
77
RUN jekyll build --trace && \
88
mkdir -p _site/en/css _site/ru/css && \
99
cp css/*.css _site/en/css/ && \
10-
cp css/*.css _site/ru/css/
10+
cp css/*.css _site/ru/css/ && \
11+
find _site/en -name "*.html" -exec sed -i 's|href="/en/|href="/|g' {} \; && \
12+
find _site/en -name "*.html" -exec sed -i 's|src="/en/|src="/|g' {} \; && \
13+
find _site/ru -name "*.html" -exec sed -i 's|href="/ru/|href="/|g' {} \; && \
14+
find _site/ru -name "*.html" -exec sed -i 's|src="/ru/|src="/|g' {} \;
1115

1216

1317
FROM golang:1.25-alpine as gobuilder

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ PORT := 8080
77
build:
88
docker buildx build -t $(IMAGE_NAME) --load --no-cache .
99

10+
build-push:
11+
docker buildx build -t $(IMAGE_NAME) --push --no-cache .
12+
1013
run: build
1114
docker run -d --name $(CONTAINER_NAME) -p $(PORT):80 $(IMAGE_NAME)
1215
@echo "Server running at http://localhost:$(PORT)"

_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Site title and subtitle. This is used in _includes/header.html
22
title: 'GameAP Documentation'
33

4+
# Domain configuration for multi-language deployment
5+
domains:
6+
en: "https://docs.gameap.com"
7+
ru: "https://docs.gameap.ru"
8+
49
# if you wish to integrate disqus on pages set your shortname here
510
disqus_shortname: ''
611

_includes/header.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{% assign lang = site.data.lang[page.lang] %}
2+
{% assign other_lang = 'ru' %}
3+
{% assign other_domain = site.domains.ru %}
4+
{% if page.lang == 'ru' %}
5+
{% assign other_lang = 'en' %}
6+
{% assign other_domain = site.domains.en %}
7+
{% endif %}
8+
{% assign clean_path = page.url | replace: '/en/', '/' | replace: '/ru/', '/' %}
29

310
<div class="container">
411
<header id="header">
@@ -9,6 +16,9 @@
916
<nav class="header-nav">
1017
<a href="http://gameap.com">{{ lang.site }}</a>
1118
<a href="https://github.com/gameap">GitHub</a>
19+
<a href="{{ other_domain }}{{ clean_path }}" class="lang-switch">
20+
{% if page.lang == 'en' %}RU{% else %}EN{% endif %}
21+
</a>
1222
</nav>
1323
</header>
1424
</div>

_layouts/default.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77

88
<title>{{ site.title }}{% if page.title %} : {{ page.title }}{% endif %}</title>
99

10+
{% assign clean_path = page.url | replace: '/ru/', '/' | replace: '/en/', '/' %}
11+
<!-- Canonical URL -->
12+
<link rel="canonical" href="{{ site.domains[page.lang] }}{{ clean_path }}">
13+
14+
<!-- Hreflang tags for language alternatives -->
15+
<link rel="alternate" hreflang="en" href="{{ site.domains.en }}{{ clean_path }}">
16+
<link rel="alternate" hreflang="ru" href="{{ site.domains.ru }}{{ clean_path }}">
17+
<link rel="alternate" hreflang="x-default" href="{{ site.domains.en }}{{ clean_path }}">
18+
1019
<link rel="stylesheet" href="{{ site.baseurl }}/css/syntax.css">
1120
<link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
1221
<link rel="stylesheet" href="{{ site.baseurl }}/css/github-markdown.css">

server/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,14 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
137137
// Check if path starts with /$lang/
138138
if lang, suffix, ok := extractLangPrefix(urlPath); ok {
139139
if lang == cfg.Lang {
140-
// Current language - serve locally
141-
serveFile(w, r, path.Join(lang, suffix))
140+
// Current language - redirect to clean URL (remove /ru/ or /en/ prefix)
141+
cleanURL := "/" + suffix
142+
if cleanURL == "/" {
143+
cleanURL = "/"
144+
}
145+
http.Redirect(w, r, cleanURL, http.StatusMovedPermanently)
142146
} else if domain, exists := cfg.Redirects[lang]; exists {
143-
// Other language from REDIRECTS - redirect
147+
// Other language from REDIRECTS - redirect to other domain with clean URL
144148
http.Redirect(w, r, fmt.Sprintf("https://%s/%s", domain, suffix), http.StatusMovedPermanently)
145149
} else {
146150
// Language not in REDIRECTS - 404

test_file.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)