refactor: use Astro i18n to avoid redirect notice
All checks were successful
Homepage Check Build (NixCN) TeamCity build finished
Homepage Prod Build (NixCN) TeamCity build finished

This commit is contained in:
2026-05-21 02:37:26 +08:00
parent 327ca25272
commit 060eb2bdc8
15 changed files with 52 additions and 46 deletions

7
Caddyfile Normal file
View File

@@ -0,0 +1,7 @@
:3000 {
root * /srv
file_server
@root path /
redir @root /zh-CN/ 302
}

View File

@@ -8,5 +8,6 @@ RUN pnpm build
FROM caddy:2-alpine AS runtime
COPY --from=builder /app/dist /srv
COPY Caddyfile /etc/caddy/Caddyfile
EXPOSE 3000
CMD ["caddy", "file-server", "--root", "/srv", "--listen", ":3000"]
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

View File

@@ -7,14 +7,12 @@ export default defineConfig({
site: 'https://meetup.nixos-cn.org',
vite: {
plugins: [tailwindcss()],
preview: {
allowedHosts: ['test.nix.org.cn', 'nix.org.cn'],
},
},
server: {
host: true,
},
redirects: {
'/': '/zh-CN/',
i18n: {
locales: ['zh-CN', 'en'],
defaultLocale: 'zh-CN',
},
});

View File

@@ -1,10 +0,0 @@
---
import CmsGuidePage from '../../components/CmsGuidePage.astro';
import { getLocalePaths, type Locale } from '../../i18n/config';
export const getStaticPaths = getLocalePaths;
const { lang } = Astro.params as { lang: Locale };
---
<CmsGuidePage locale={lang} />

View File

@@ -1,10 +0,0 @@
---
import EventGuidePage from '../../components/EventGuidePage.astro';
import { getLocalePaths, type Locale } from '../../i18n/config';
export const getStaticPaths = getLocalePaths;
const { lang } = Astro.params as { lang: Locale };
---
<EventGuidePage locale={lang} />

View File

@@ -1,10 +0,0 @@
---
import HomePage from '../../components/HomePage.astro';
import { getLocalePaths, type Locale } from '../../i18n/config';
export const getStaticPaths = getLocalePaths;
const { lang } = Astro.params as { lang: Locale };
---
<HomePage locale={lang} />

View File

@@ -1,10 +0,0 @@
---
import SouvenirPage from '../../components/SouvenirPage.astro';
import { getLocalePaths, type Locale } from '../../i18n/config';
export const getStaticPaths = getLocalePaths;
const { lang } = Astro.params as { lang: Locale };
---
<SouvenirPage locale={lang} />

View File

@@ -0,0 +1,5 @@
---
import CmsGuidePage from '../../components/CmsGuidePage.astro';
---
<CmsGuidePage locale='en' />

View File

@@ -0,0 +1,5 @@
---
import EventGuidePage from '../../components/EventGuidePage.astro';
---
<EventGuidePage locale='en' />

5
src/pages/en/index.astro Normal file
View File

@@ -0,0 +1,5 @@
---
import HomePage from '../../components/HomePage.astro';
---
<HomePage locale='en' />

View File

@@ -0,0 +1,5 @@
---
import SouvenirPage from '../../components/SouvenirPage.astro';
---
<SouvenirPage locale='en' />

View File

@@ -0,0 +1,5 @@
---
import CmsGuidePage from '../../components/CmsGuidePage.astro';
---
<CmsGuidePage locale='zh-CN' />

View File

@@ -0,0 +1,5 @@
---
import EventGuidePage from '../../components/EventGuidePage.astro';
---
<EventGuidePage locale='zh-CN' />

View File

@@ -0,0 +1,5 @@
---
import HomePage from '../../components/HomePage.astro';
---
<HomePage locale='zh-CN' />

View File

@@ -0,0 +1,5 @@
---
import SouvenirPage from '../../components/SouvenirPage.astro';
---
<SouvenirPage locale='zh-CN' />