Skip to content

Commit

Permalink
docs: add support for multiple languages
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Sep 17, 2024
1 parent 6d54b72 commit 914fb4a
Show file tree
Hide file tree
Showing 17 changed files with 595 additions and 147 deletions.
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ pnpm-lock.yaml
ui/artalk/src/api/v2.ts
docs/swagger/swagger.json
docs/swagger/swagger.yaml
docs/docs/**
docs/docs/**/*.md
docs/docs/.vitepress/dist/**
docs/docs/.vitepress/cache/**
ui/artalk-sidebar/src/lib/md5.js
ui/artalk/src/lib/detect.ts
**/dist/**
141 changes: 141 additions & 0 deletions docs/docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { defineConfig } from 'vitepress'

export const en = defineConfig({
lang: 'en-US',
description: 'A Self-hosted Comment System.',

themeConfig: {
sidebar: {
'/en/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: '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: 'Accounts and Multi-site', link: '/en/guide/backend/multi-site.md' },
{ text: 'Resolve Relative Path', link: '/en/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: 'Multi-language', link: '/en/guide/frontend/i18n.md' },
{ text: 'Development Documentation', link: '/en/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: 'Deployment Instructions',
collapsed: true,
items: [
{ text: 'Daemon', link: '/en/guide/backend/daemon.md' },
{ text: 'Reverse Proxy', link: '/en/guide/backend/reverse-proxy.md' },
{ text: 'Build', link: '/en/develop/contributing.md' },
{ text: 'Program Upgrade', link: '/en/guide/backend/update.md' },
{ text: 'Docker', link: '/en/guide/backend/docker.md' },
],
},
{
text: 'More Content',
collapsed: true,
items: [
{ text: 'Security', link: '/en/guide/security.md' },
{ text: 'Additional Reading', link: '/en/guide/extras.md' },
{ text: 'Case Studies', link: '/en/guide/cases.md' },
{ text: 'About Us', link: '/en/guide/about.md' },
],
},
],
'/en/develop/': [
{
text: 'Development Documentation',
items: [
{ text: 'Development Instructions', link: '/en/develop/index.md' },
{ text: 'Contribution Guide', link: '/en/develop/contributing.md' },
{ 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: 'HTTP API',
link: 'https://artalk.js.org/http-api.html',
},
],
},
],
},

nav: [
{
text: 'Introduction',
link: '/en/guide/intro',
},
{
text: 'Deployment',
link: '/en/guide/deploy',
},
{
text: 'Configuration',
link: '/en/guide/backend/config',
},
{
text: 'Migration',
link: '/en/guide/transfer',
},
{
text: 'Cases',
link: '/en/guide/cases',
},
{
text: 'Development',
link: '/en/develop/',
},
{
text: 'Links',
items: [
{
text: 'Code Repository',
link: 'https://github.com/ArtalkJS/Artalk',
},
],
},
],

editLink: {
pattern: 'https://github.com/ArtalkJS/Artalk/edit/master/docs/docs/:path',
text: 'Improve this document',
},
},
})
12 changes: 12 additions & 0 deletions docs/docs/.vitepress/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'vitepress'
import { shared } from './shared'
import { zh } from './zh'
import { en } from './en'

export default defineConfig({
...shared,
locales: {
root: { label: '简体中文', ...zh },
en: { label: 'English', ...en },
},
})
72 changes: 72 additions & 0 deletions docs/docs/.vitepress/config/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { defineConfig } from 'vitepress'
import iterator from 'markdown-it-for-inline'
import * as Version from '../../code/ArtalkVersion.json'

export const shared = defineConfig({
title: 'Artalk',

// TODO: Uncomment after move default language to subfolder
// 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'}],
['meta', { property: 'og:site_name', content: 'Artalk' }],
['meta', { property: 'og:image', content: 'https://artalk.js.org/assets/images/artalk-banner.png' }],
['meta', { property: 'og:url', content: 'https://artalk.js.org/' }],
['meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi' }],
],

markdown: {
// @link https://github.com/shikijs/shiki
theme: {
light: 'github-light',
dark: 'github-dark',
},
config: (md) => {
md.use(iterator, 'artalk_version', 'text', function (tokens, idx) {
tokens[idx].content = tokens[idx].content.replace(/:ArtalkVersion:/g, Version.latest)
})
md.use(iterator, 'artalk_version_link', 'link_open', (tokens, idx) => {
const href = tokens[idx].attrGet('href')
tokens[idx].attrSet('href', href.replace(/:ArtalkVersion:/g, Version.latest))
})
},
},

sitemap: {
hostname: 'https://artalk.js.org',
transformItems(items) {
return items.filter((item) => !item.url.includes('migration'))
},
},

lastUpdated: true,
cleanUrls: true,
metaChunk: true,

themeConfig: {
socialLinks: [{ icon: 'github', link: 'https://github.com/ArtalkJS/Artalk' }],

search: {
provider: 'algolia',
options: {
appId: '2WNJ32WVTY',
apiKey: '6c6ebc345a87b738264f19095b78c91c',
indexName: 'artalk-js',
},
},
},

vite: {
server: {
open: '/guide/intro.html',
},
},
})
Original file line number Diff line number Diff line change
@@ -1,61 +1,8 @@
import { defineConfig } from 'vitepress'
import iterator from 'markdown-it-for-inline'
import * as Version from '../code/ArtalkVersion.json'

export default defineConfig({
title: 'Artalk',
description: '一款简洁的自托管评论系统',
export const zh = defineConfig({
lang: 'zh-CN',

head: [
['link', { rel: 'icon', href: '/favicon.png' }],
[
'meta',
{
name: 'viewport',
content:
'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi',
},
],
],

lastUpdated: true,

markdown: {
// @link https://github.com/shikijs/shiki
theme: {
light: 'github-light',
dark: 'github-dark',
},
config: (md) => {
md.use(iterator, 'artalk_version', 'text', function (tokens, idx) {
tokens[idx].content = tokens[idx].content.replace(
/:ArtalkVersion:/g,
Version.latest,
)
})
md.use(iterator, 'artalk_version_link', 'link_open', (tokens, idx) => {
const href = tokens[idx].attrGet('href')
tokens[idx].attrSet(
'href',
href.replace(/:ArtalkVersion:/g, Version.latest),
)
})
},
},

locales: {
root: {
label: '简体中文',
lang: 'zh',
link: 'https://artalk.js.org/',
},
en: {
label: 'English',
lang: 'en',
link: 'https://artalk-js-org.translate.goog/guide/intro?_x_tr_sl=auto&_x_tr_tl=en-US&_x_tr_hl=en-US&_x_tr_pto=wapp',
},
},
description: '由 Golang 驱动的自托管评论系统',

themeConfig: {
sidebar: {
Expand Down Expand Up @@ -192,31 +139,9 @@ export default defineConfig({
},
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/ArtalkJS/Artalk' },
],

search: {
provider: 'algolia',
options: {
appId: '2WNJ32WVTY',
apiKey: '6c6ebc345a87b738264f19095b78c91c',
indexName: 'artalk-js',
searchParameters: {
facetFilters: ['lang:zh-CN'],
},
},
},

editLink: {
pattern: 'https://github.com/ArtalkJS/Artalk/edit/master/docs/docs/:path',
text: '完善文档',
},
},

vite: {
server: {
open: '/guide/intro.html',
},
},
})
4 changes: 2 additions & 2 deletions docs/docs/.vitepress/theme/Artalk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function initArtalk(conf: any) {
Artalk.use(ArtalkKatexPlugin)
Artalk.use(ArtalkLightboxPlugin, {
lightGallery: {
lib: async () => (await import('lightgallery')).default
}
lib: async () => (await import('lightgallery')).default,
},
})
artalk = Artalk.init({
Expand Down
Loading

0 comments on commit 914fb4a

Please sign in to comment.