Skip to content

Commit

Permalink
chore(docs): add support for auto-redirect to language-specific docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Sep 18, 2024
1 parent 349eb6f commit 7be1a11
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 105 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ Artalk.init({

<!-- prettier-ignore-end -->

[**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

Expand Down
4 changes: 2 additions & 2 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ Artalk.init({

<!-- prettier-ignore-end -->

[**了解更多 →**](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

Expand Down
82 changes: 41 additions & 41 deletions docs/docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,85 +6,85 @@ export const en = defineConfig({

themeConfig: {
sidebar: {
'/en/guide/': [
'/guide/': [
{
text: 'Quick Start',
collapsed: false,
items: [
{ text: 'Project Introduction', link: '/en/guide/intro.md' },
{ text: 'Program Deployment', link: '/en/guide/deploy.md' },
{ text: 'Data Migration', link: '/en/guide/transfer.md' },
{ text: 'Project Introduction', link: '/guide/intro.md' },
{ text: 'Program Deployment', link: '/guide/deploy.md' },
{ text: 'Data Migration', link: '/guide/transfer.md' },
],
},
{
text: 'Core Guide',
collapsed: false,
items: [
{ text: 'Sidebar', link: '/en/guide/frontend/sidebar.md' },
{ text: 'Email Notification', link: '/en/guide/backend/email.md' },
{ text: 'Multi-channel Notification', link: '/en/guide/backend/admin_notify.md' },
{ text: 'Social Login', link: '/en/guide/frontend/auth.md' },
{ text: 'Comment Moderation', link: '/en/guide/backend/moderator.md' },
{ text: 'Captcha', link: '/en/guide/backend/captcha.md' },
{ text: 'Image Upload', link: '/en/guide/backend/img-upload.md' },
{ text: 'Admins and Multi-Site', link: '/en/guide/backend/multi-site.md' },
{ text: 'Resolve Relative Path', link: '/en/guide/backend/relative-path.md' },
{ text: 'Sidebar', link: '/guide/frontend/sidebar.md' },
{ text: 'Email Notification', link: '/guide/backend/email.md' },
{ text: 'Multi-channel Notification', link: '/guide/backend/admin_notify.md' },
{ text: 'Social Login', link: '/guide/frontend/auth.md' },
{ text: 'Comment Moderation', link: '/guide/backend/moderator.md' },
{ text: 'Captcha', link: '/guide/backend/captcha.md' },
{ text: 'Image Upload', link: '/guide/backend/img-upload.md' },
{ text: 'Admins and Multi-Site', link: '/guide/backend/multi-site.md' },
{ text: 'Resolve Relative Path', link: '/guide/backend/relative-path.md' },
],
},
{
text: 'Advanced Guide',
collapsed: false,
items: [
{ text: 'Emoticons', link: '/en/guide/frontend/emoticons.md' },
{ text: 'Page View Statistics', link: '/en/guide/frontend/pv.md' },
{ text: 'LaTeX', link: '/en/guide/frontend/latex.md' },
{ text: 'Image Lightbox', link: '/en/guide/frontend/lightbox.md' },
{ text: 'Image Lazy Load', link: '/en/guide/frontend/img-lazy-load.md' },
{ text: 'IP Region', link: '/en/guide/frontend/ip-region.md' },
{ text: 'Localization', link: '/en/guide/frontend/i18n.md' },
{ text: 'Development Documentation', link: '/en/develop/index.md' },
{ text: 'Emoticons', link: '/guide/frontend/emoticons.md' },
{ text: 'Page View Statistics', link: '/guide/frontend/pv.md' },
{ text: 'LaTeX', link: '/guide/frontend/latex.md' },
{ text: 'Image Lightbox', link: '/guide/frontend/lightbox.md' },
{ text: 'Image Lazy Load', link: '/guide/frontend/img-lazy-load.md' },
{ text: 'IP Region', link: '/guide/frontend/ip-region.md' },
{ text: 'Localization', link: '/guide/frontend/i18n.md' },
{ text: 'Development Documentation', link: '/develop/index.md' },
],
},
{
text: 'Configuration Documentation',
collapsed: false,
items: [
{ text: 'Environment Variables', link: '/en/guide/env.md' },
{ text: 'Configuration File', link: '/en/guide/backend/config.md' },
{ text: 'Interface Configuration', link: '/en/guide/frontend/config.md' },
{ text: 'Environment Variables', link: '/guide/env.md' },
{ text: 'Configuration File', link: '/guide/backend/config.md' },
{ text: 'Interface Configuration', link: '/guide/frontend/config.md' },
],
},
{
text: 'Deployment Instructions',
collapsed: false,
items: [
{ text: 'Daemon Process', link: '/en/guide/backend/daemon.md' },
{ text: 'Reverse Proxy', link: '/en/guide/backend/reverse-proxy.md' },
{ text: 'Daemon Process', link: '/guide/backend/daemon.md' },
{ text: 'Reverse Proxy', link: '/guide/backend/reverse-proxy.md' },
{
text: 'Compile Source',
link: 'https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md',
},
{ text: 'Program Upgrade', link: '/en/guide/backend/update.md' },
{ text: 'Docker', link: '/en/guide/backend/docker.md' },
{ text: 'Program Upgrade', link: '/guide/backend/update.md' },
{ text: 'Docker', link: '/guide/backend/docker.md' },
],
},
],
'/en/develop/': [
'/develop/': [
{
text: 'Development Documentation',
items: [
{ text: 'Development Instructions', link: '/en/develop/index.md' },
{ text: 'Development Instructions', link: '/develop/index.md' },
{
text: 'Contribution Guide',
link: 'https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md',
target: '_blank',
},
{ text: 'Import to Blog', link: '/en/develop/import-blog.md' },
{ text: 'Import to Framework', link: '/en/develop/import-framework.md' },
{ text: 'Frontend API', link: '/en/develop/fe-api.md' },
{ text: 'Frontend Event', link: '/en/develop/event.md' },
{ text: 'Plugin Development', link: '/en/develop/plugin.md' },
{ text: 'Compatibility', link: '/en/develop/compatibility.md' },
{ text: 'Import to Blog', link: '/develop/import-blog.md' },
{ text: 'Import to Framework', link: '/develop/import-framework.md' },
{ text: 'Frontend API', link: '/develop/fe-api.md' },
{ text: 'Frontend Event', link: '/develop/event.md' },
{ text: 'Plugin Development', link: '/develop/plugin.md' },
{ text: 'Compatibility', link: '/develop/compatibility.md' },
{
text: 'HTTP API',
link: 'https://artalk.js.org/http-api.html',
Expand All @@ -97,23 +97,23 @@ export const en = defineConfig({
nav: [
{
text: 'Introduction',
link: '/en/guide/intro',
link: '/guide/intro',
},
{
text: 'Deployment',
link: '/en/guide/deploy',
link: '/guide/deploy',
},
{
text: 'Configuration',
link: '/en/guide/backend/config',
link: '/guide/backend/config',
},
{
text: 'Migration',
link: '/en/guide/transfer',
link: '/guide/transfer',
},
{
text: 'Development',
link: '/en/develop/',
link: '/develop/',
},
],

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/.vitepress/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { en } from './en'
export default defineConfig({
...shared,
locales: {
root: { label: '简体中文', ...zh },
en: { label: 'English', ...en },
root: { label: 'English', ...en },
zh: { label: '简体中文', ...zh },
},
})
4 changes: 0 additions & 4 deletions docs/docs/.vitepress/config/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ 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' }],
Expand Down
96 changes: 48 additions & 48 deletions docs/docs/.vitepress/config/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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/',
},
],

Expand Down
9 changes: 8 additions & 1 deletion docs/docs/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<script setup>
import DefaultTheme from 'vitepress/theme'
import { onMounted } from 'vue'
import { inBrowser, useData } from 'vitepress'
import { watchEffect } from 'vue'
import './style.scss'
const { Layout } = DefaultTheme
const { lang } = useData()
watchEffect(() => {
if (inBrowser)
document.cookie = `nf_lang=${lang.value}; expires=Mon, 1 Jan 2030 00:00:00 UTC; path=/`
})
</script>

<template>
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/public/_headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/assets/*
cache-control: max-age=31536000
cache-control: immutable
8 changes: 8 additions & 0 deletions docs/docs/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/guide/* /zh/guide/:splat 302! Language=zh
/guide/* /en/guide/:splat 302! Language=en
/guide/* /en/guide/:splat 302!

/develop/* /zh/develop/:splat 302! Language=zh
/develop/* /en/develop/:splat 302! Language=en
/develop/* /en/develop/:splat 302!

Loading

0 comments on commit 7be1a11

Please sign in to comment.