From 876f81682b0b9f8e52bed1a0a8fdd084693b50fb Mon Sep 17 00:00:00 2001 From: qwqcode Date: Wed, 18 Sep 2024 09:16:23 +0800 Subject: [PATCH] chore(docs): add support for auto-redirect to language-specific docs --- README.md | 4 +- README.zh.md | 4 +- docs/docs/.vitepress/config/index.ts | 2 +- docs/docs/.vitepress/config/shared.ts | 7 +- docs/docs/.vitepress/config/zh.ts | 96 +++++++++++----------- docs/docs/.vitepress/theme/Layout.vue | 9 +- docs/docs/public/_headers | 3 + docs/docs/public/_redirects | 8 ++ docs/docs/zh/guide/backend/admin_notify.md | 2 +- docs/docs/zh/guide/backend/captcha.md | 2 +- docs/docs/zh/guide/backend/config.md | 14 ++-- docs/docs/zh/guide/backend/docker.md | 4 +- docs/docs/zh/guide/backend/email.md | 2 +- docs/docs/zh/guide/backend/img-upload.md | 4 +- docs/docs/zh/guide/backend/moderator.md | 2 +- docs/docs/zh/guide/backend/multi-site.md | 2 +- docs/docs/zh/guide/frontend/auth.md | 2 +- docs/docs/zh/guide/frontend/config.md | 6 +- docs/docs/zh/guide/frontend/emoticons.md | 2 +- docs/docs/zh/guide/frontend/sidebar.md | 2 +- docs/landing/index.html | 1 - docs/landing/src/i18n/zh-CN.ts | 10 +-- 22 files changed, 100 insertions(+), 88 deletions(-) create mode 100644 docs/docs/public/_headers create mode 100644 docs/docs/public/_redirects diff --git a/README.md b/README.md index 45348d27..cdef4c92 100644 --- a/README.md +++ b/README.md @@ -94,13 +94,13 @@ Artalk.init({ -[**Learn More →**](https://artalk.js.org/guide/deploy.html) +[**Learn More →**](https://artalk.js.org/en/guide/deploy.html) ## For Developers Pull requests are welcome! -See [Development](https://artalk.js.org/develop/) and [Contributing](./CONTRIBUTING.md) for information on working with the codebase, getting a local development setup, and contributing changes. +See [Development](https://artalk.js.org/en/develop/) and [Contributing](./CONTRIBUTING.md) for information on working with the codebase, getting a local development setup, and contributing changes. ## Contributors diff --git a/README.zh.md b/README.zh.md index 7651cf76..ac79515a 100644 --- a/README.zh.md +++ b/README.zh.md @@ -94,13 +94,13 @@ Artalk.init({ -[**了解更多 →**](https://artalk.js.org/guide/deploy.html) +[**了解更多 →**](https://artalk.js.org/zh/guide/deploy.html) ## For Developers Pull requests are welcome! -See [Development](https://artalk.js.org/develop/) and [Contributing](./CONTRIBUTING.md) for information on working with the codebase, getting a local development setup, and contributing changes. +See [Development](https://artalk.js.org/zh/develop/) and [Contributing](./CONTRIBUTING.md) for information on working with the codebase, getting a local development setup, and contributing changes. ## Contributors diff --git a/docs/docs/.vitepress/config/index.ts b/docs/docs/.vitepress/config/index.ts index 5168761b..d41e2fc5 100644 --- a/docs/docs/.vitepress/config/index.ts +++ b/docs/docs/.vitepress/config/index.ts @@ -6,7 +6,7 @@ import { en } from './en' export default defineConfig({ ...shared, locales: { - root: { label: '简体中文', ...zh }, en: { label: 'English', ...en }, + zh: { label: '简体中文', ...zh }, }, }) diff --git a/docs/docs/.vitepress/config/shared.ts b/docs/docs/.vitepress/config/shared.ts index fdd86ecb..e8c5e2e7 100644 --- a/docs/docs/.vitepress/config/shared.ts +++ b/docs/docs/.vitepress/config/shared.ts @@ -5,14 +5,9 @@ import * as Version from '../../code/ArtalkVersion.json' export const shared = defineConfig({ title: 'Artalk', - rewrites: { - 'zh/:rest*': ':rest*', - }, - /* prettier-ignore */ head: [ ['link', { rel: 'icon', type: 'image/png', href: '/favicon.png' }], - ['meta', { name: 'theme-color', content: '#007bff' }], ['meta', { property: 'og:type', content: 'website' }], ['meta', { property: 'og:locale', content: 'en' }], ['meta', { property: 'og:title', content: 'Artalk - A Self-hosted Comment System'}], @@ -65,7 +60,7 @@ export const shared = defineConfig({ vite: { server: { - open: '/guide/intro.html', + open: '/zh/guide/intro.html', }, }, }) diff --git a/docs/docs/.vitepress/config/zh.ts b/docs/docs/.vitepress/config/zh.ts index fa1ea334..9fc04e1a 100644 --- a/docs/docs/.vitepress/config/zh.ts +++ b/docs/docs/.vitepress/config/zh.ts @@ -6,88 +6,88 @@ export const zh = defineConfig({ themeConfig: { sidebar: { - '/guide/': [ + '/zh/guide/': [ { text: '快速开始', collapsed: false, items: [ - { text: '项目介绍', link: '/guide/intro.md' }, - { text: '程序部署', link: '/guide/deploy.md' }, - { text: '数据迁移', link: '/guide/transfer.md' }, + { text: '项目介绍', link: '/zh/guide/intro.md' }, + { text: '程序部署', link: '/zh/guide/deploy.md' }, + { text: '数据迁移', link: '/zh/guide/transfer.md' }, ], }, { text: '核心指南', collapsed: false, items: [ - { text: '侧边栏', link: '/guide/frontend/sidebar.md' }, - { text: '邮件通知', link: '/guide/backend/email.md' }, - { text: '多元推送', link: '/guide/backend/admin_notify.md' }, - { text: '社交登录', link: '/guide/frontend/auth.md' }, - { text: '评论审核', link: '/guide/backend/moderator.md' }, - { text: '验证码', link: '/guide/backend/captcha.md' }, - { text: '图片上传', link: '/guide/backend/img-upload.md' }, - { text: '账户与多站点', link: '/guide/backend/multi-site.md' }, - { text: '解析相对路径', link: '/guide/backend/relative-path.md' }, + { text: '侧边栏', link: '/zh/guide/frontend/sidebar.md' }, + { text: '邮件通知', link: '/zh/guide/backend/email.md' }, + { text: '多元推送', link: '/zh/guide/backend/admin_notify.md' }, + { text: '社交登录', link: '/zh/guide/frontend/auth.md' }, + { text: '评论审核', link: '/zh/guide/backend/moderator.md' }, + { text: '验证码', link: '/zh/guide/backend/captcha.md' }, + { text: '图片上传', link: '/zh/guide/backend/img-upload.md' }, + { text: '账户与多站点', link: '/zh/guide/backend/multi-site.md' }, + { text: '解析相对路径', link: '/zh/guide/backend/relative-path.md' }, ], }, { text: '进阶指南', collapsed: false, items: [ - { text: '表情包', link: '/guide/frontend/emoticons.md' }, - { text: '浏览量统计', link: '/guide/frontend/pv.md' }, - { text: 'LaTeX', link: '/guide/frontend/latex.md' }, - { text: '图片灯箱', link: '/guide/frontend/lightbox.md' }, - { text: '图片懒加载', link: '/guide/frontend/img-lazy-load.md' }, - { text: 'IP 属地', link: '/guide/frontend/ip-region.md' }, - { text: '多语言', link: '/guide/frontend/i18n.md' }, - { text: '开发文档', link: '/develop/index.md' }, + { text: '表情包', link: '/zh/guide/frontend/emoticons.md' }, + { text: '浏览量统计', link: '/zh/guide/frontend/pv.md' }, + { text: 'LaTeX', link: '/zh/guide/frontend/latex.md' }, + { text: '图片灯箱', link: '/zh/guide/frontend/lightbox.md' }, + { text: '图片懒加载', link: '/zh/guide/frontend/img-lazy-load.md' }, + { text: 'IP 属地', link: '/zh/guide/frontend/ip-region.md' }, + { text: '多语言', link: '/zh/guide/frontend/i18n.md' }, + { text: '开发文档', link: '/zh/develop/index.md' }, ], }, { text: '配置文档', collapsed: false, items: [ - { text: '环境变量', link: '/guide/env.md' }, - { text: '配置文件', link: '/guide/backend/config.md' }, - { text: '界面配置', link: '/guide/frontend/config.md' }, + { text: '环境变量', link: '/zh/guide/env.md' }, + { text: '配置文件', link: '/zh/guide/backend/config.md' }, + { text: '界面配置', link: '/zh/guide/frontend/config.md' }, ], }, { text: '部署说明', collapsed: true, items: [ - { text: '守护进程', link: '/guide/backend/daemon.md' }, - { text: '反向代理', link: '/guide/backend/reverse-proxy.md' }, - { text: '编译构建', link: '/develop/contributing.md' }, - { text: '程序升级', link: '/guide/backend/update.md' }, - { text: 'Docker', link: '/guide/backend/docker.md' }, + { text: '守护进程', link: '/zh/guide/backend/daemon.md' }, + { text: '反向代理', link: '/zh/guide/backend/reverse-proxy.md' }, + { text: '编译构建', link: '/zh/develop/contributing.md' }, + { text: '程序升级', link: '/zh/guide/backend/update.md' }, + { text: 'Docker', link: '/zh/guide/backend/docker.md' }, ], }, { text: '更多内容', collapsed: true, items: [ - { text: '安全防范', link: '/guide/security.md' }, - { text: '扩展阅读', link: '/guide/extras.md' }, - { text: '案例展示', link: '/guide/cases.md' }, - { text: '关于我们', link: '/guide/about.md' }, + { text: '安全防范', link: '/zh/guide/security.md' }, + { text: '扩展阅读', link: '/zh/guide/extras.md' }, + { text: '案例展示', link: '/zh/guide/cases.md' }, + { text: '关于我们', link: '/zh/guide/about.md' }, ], }, ], - '/develop/': [ + '/zh/develop/': [ { text: '开发文档', items: [ - { text: '开发说明', link: '/develop/index.md' }, - { text: '贡献指南', link: '/develop/contributing.md' }, - { text: '置入博客', link: '/develop/import-blog.md' }, - { text: '置入框架', link: '/develop/import-framework.md' }, - { text: '前端 API', link: '/develop/fe-api.md' }, - { text: '前端 Event', link: '/develop/event.md' }, - { text: '插件开发', link: '/develop/plugin.md' }, - { text: '兼容性', link: '/develop/compatibility.md' }, + { text: '开发说明', link: '/zh/develop/index.md' }, + { text: '贡献指南', link: '/zh/develop/contributing.md' }, + { text: '置入博客', link: '/zh/develop/import-blog.md' }, + { text: '置入框架', link: '/zh/develop/import-framework.md' }, + { text: '前端 API', link: '/zh/develop/fe-api.md' }, + { text: '前端 Event', link: '/zh/develop/event.md' }, + { text: '插件开发', link: '/zh/develop/plugin.md' }, + { text: '兼容性', link: '/zh/develop/compatibility.md' }, { text: 'HTTP API', link: 'https://artalk.js.org/http-api.html', @@ -101,27 +101,27 @@ export const zh = defineConfig({ // NavbarItem { text: '介绍', - link: '/guide/intro', + link: '/zh/guide/intro', }, { text: '部署', - link: '/guide/deploy', + link: '/zh/guide/deploy', }, { text: '配置', - link: '/guide/backend/config', + link: '/zh/guide/backend/config', }, { text: '迁移', - link: '/guide/transfer', + link: '/zh/guide/transfer', }, { text: '案例', - link: '/guide/cases', + link: '/zh/guide/cases', }, { text: '开发', - link: '/develop/', + link: '/zh/develop/', }, ], diff --git a/docs/docs/.vitepress/theme/Layout.vue b/docs/docs/.vitepress/theme/Layout.vue index 9f6b2f53..5a4d7918 100644 --- a/docs/docs/.vitepress/theme/Layout.vue +++ b/docs/docs/.vitepress/theme/Layout.vue @@ -1,9 +1,16 @@