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 876f816
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 88 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
2 changes: 1 addition & 1 deletion 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 },
zh: { label: '简体中文', ...zh },
},
})
7 changes: 1 addition & 6 deletions docs/docs/.vitepress/config/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}],
Expand Down Expand Up @@ -65,7 +60,7 @@ export const shared = defineConfig({

vite: {
server: {
open: '/guide/intro.html',
open: '/zh/guide/intro.html',
},
},
})
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!

2 changes: 1 addition & 1 deletion docs/docs/zh/guide/backend/admin_notify.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Artalk 支持通过多元推送功能以多种方式发送管理员通知。

支持 **Telegram****飞书****钉钉****Bark****Slack****LINE**,并且多种方式可以同时启用。

你可以在 [控制中心](/guide/frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](/guide/backend/config.md#多元推送-admin-notify)[环境变量](/guide/env.md#多元推送) 进行配置。
你可以在 [控制中心](../frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](./config.md#多元推送-admin-notify)[环境变量](../env.md#多元推送) 进行配置。

## 配置文件

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/zh/guide/backend/captcha.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Artalk 内置图片验证码功能,你可以配置操作频率限制,当超

目前 Artalk 支持:Turnstile、reCAPTCHA、hCaptcha、极验。

你可以在 [控制中心](/guide/frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](/guide/backend/config.md#验证码-captcha)[环境变量](/guide/env.md#验证码) 进行配置。
你可以在 [控制中心](../frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](./config.md#验证码-captcha)[环境变量](../env.md#验证码) 进行配置。

## 配置文件

Expand Down
14 changes: 7 additions & 7 deletions docs/docs/zh/guide/backend/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 轻松配置

推荐在侧边栏 “[控制中心](/guide/frontend/sidebar.md)” 通过图形界面修改配置,无需手动编辑配置文件。
推荐在侧边栏 “[控制中心](../frontend/sidebar.md)” 通过图形界面修改配置,无需手动编辑配置文件。

## 环境变量

Expand Down Expand Up @@ -114,7 +114,7 @@ http:

Artalk 支持多站点,你可以创建多个管理员账户,为其分配站点,让你的朋友们共用同一个后端程序。

详情参考:[管理员 × 多站点](/guide/backend/multi-site.md)
详情参考:[管理员 × 多站点](./multi-site.md)

## 可信域名 `trusted_domains`

Expand Down Expand Up @@ -184,25 +184,25 @@ frontend:

配置邮件通知,让回复通过邮件的形式通知目标用户,你可以自定义邮件发送者名称、标题、模版等。

详情参考:[后端 · 邮件通知](/guide/backend/email.md)
详情参考:[后端 · 邮件通知](./email.md)

## 多元推送 `admin_notify`

你可以配置多种消息发送方式,例如飞书、Telegram 等,当收到新的评论时通知管理员。

详情参考:[后端 · 多元推送](/guide/backend/admin_notify.md)
详情参考:[后端 · 多元推送](./admin_notify.md)

## 评论审核 `moderator`

配置评论审核来自动拦截垃圾评论。

详情参考:[后端 · 评论审核](/guide/backend/moderator.md)
详情参考:[后端 · 评论审核](./moderator.md)

## 验证码 `captcha`

支持图片、滑动验证码,通过验证码对请求频率进行限制。

详情参考:[后端 · 验证码](/guide/backend/captcha.md)
详情参考:[后端 · 验证码](./captcha.md)

## 高速缓存 `cache`

Expand Down Expand Up @@ -356,5 +356,5 @@ test_file: ./data/artalk.log

配置文件相关代码:[/internal/config/config.go](https://github.com/ArtalkJS/Artalk/blob/master/internal/config/config.go)

前往:[前端配置](/guide/frontend/config.md)
前往:[前端配置](../frontend/config.md)
:::
4 changes: 2 additions & 2 deletions docs/docs/zh/guide/backend/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ docker pull artalk/artalk-go

:::tip

推荐使用 Docker Compose,可参考 [程序部署](/guide/deploy) 页面的步骤。
推荐使用 Docker Compose,可参考 [程序部署](../deploy) 页面的步骤。

:::

Expand Down Expand Up @@ -98,4 +98,4 @@ docker exec -it artalk bash

## 多平台兼容性

Docker 镜像暂仅提供 x86、arm64 的镜像构建,如需更多平台架构版本,请下载 [二进制构建部署](/guide/deploy.md#普通方式部署)
Docker 镜像暂仅提供 x86、arm64 的镜像构建,如需更多平台架构版本,请下载 [二进制构建部署](../deploy.md#普通方式部署)
2 changes: 1 addition & 1 deletion docs/docs/zh/guide/backend/email.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Artalk 支持通过 SMTP 协议、阿里云邮件推送、调用系统 Sendmail 命令等方式向用户发送邮件通知。

你可以在 [控制中心](/guide/frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](/guide/backend/config.md#邮件通知-email)[环境变量](/guide/env.md#邮件通知) 进行配置。
你可以在 [控制中心](../frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](./config.md#邮件通知-email)[环境变量](../env.md#邮件通知) 进行配置。

## 配置文件

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/zh/guide/backend/img-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Artalk 提供图片上传功能,支持限制图片大小、上传频率等,你还能结合 UpGit 将图片上传到图床。

你可以在 [控制中心](/guide/frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](/guide/backend/config.md#图片上传-img_upload)[环境变量](/guide/env.md#图片上传) 进行配置。
你可以在 [控制中心](../frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](./config.md#图片上传-img_upload)[环境变量](../env.md#图片上传) 进行配置。

## 配置文件

Expand Down Expand Up @@ -61,7 +61,7 @@ docker run -d --name artalk -v /path/to/upgit:/usr/bin/upgit -v /path/to/artalk:

频率限制跟随 `captcha` 验证码配置,当超出限制将弹出验证码。

可参考:[后端 · 验证码](/guide/backend/captcha.md)
可参考:[后端 · 验证码](./captcha.md)

## path

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/zh/guide/backend/moderator.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Artalk 支持多种评论过滤方式以拦截垃圾评论,支持通过 Akismet、腾讯云内容安全、阿里云内容安全 等在线 API 实现垃圾评论识别和拦截,也可通过本地离线关键词词库过滤评论,结合[验证码](./captcha.md)功能进一步提高评论审核强度,让垃圾评论没有容身之地。

你可以在 [控制中心](/guide/frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](/guide/backend/config.md#评论审核-moderator)[环境变量](/guide/env.md#评论审核) 进行配置。
你可以在 [控制中心](../frontend/sidebar.md#设置) 的设置界面修改此配置,也可以通过 [配置文件](./config.md#评论审核-moderator)[环境变量](../env.md#评论审核) 进行配置。

## 配置文件

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/zh/guide/backend/multi-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ admin_users:

::: tip

可以通过环境变量配置管理员账户,参考:[环境变量配置](/guide/env.md)
可以通过环境变量配置管理员账户,参考:[环境变量配置](../env.md)

:::

Expand Down
Loading

0 comments on commit 876f816

Please sign in to comment.