Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 21, 2023
1 parent 2777b80 commit 2e3e9d0
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist/
external/
.data
.temp
.vitepress/cache
Expand Down
88 changes: 57 additions & 31 deletions .vitepress/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,65 @@
import { defineConfig } from '@koishijs/vitepress'
import { resolve } from 'path'
import { mkdir, rm, symlink } from 'fs/promises'

const isDev = process.env.NODE_ENV === 'development' || process.env.VERCEL_ENV === 'preview'

export default async () => defineConfig({
title: 'Koishi',
description: '创建跨平台、可扩展、高性能的机器人',

locales: {
'en-US': require('./en-US'),
'zh-CN': require('./zh-CN'),
...(isDev ? {
'zh-TW': require('./zh-TW'),
'de-DE': require('./de-DE'),
'fr-FR': require('./fr-FR'),
'ja-JP': require('./ja-JP'),
'ru-RU': require('./ru-RU'),
} : {}),
},

themeConfig: {
indexName: 'docs',
logo: '/logo.png',

socialLinks: {
github: 'https://github.com/koishijs/koishi',
const external = [] // ['assets', 'cache']
const locales = ['en-US', 'zh-CN', 'zh-TW', 'de-DE', 'fr-FR', 'ja-JP', 'ru-RU']

export default async () => {
for (const locale of locales) {
await rm(resolve(__dirname, '../..', locale, 'external'), { recursive: true, force: true })
await mkdir(resolve(__dirname, '../..', locale, 'external'), { recursive: true })
}

for (const name of external) {
try {
const root = require.resolve(`@root/${name}/package.json`)
for (const locale of locales) {
await symlink(
resolve(root, '../docs', locale),
resolve(resolve(__dirname, '../..', locale, 'external'), name),
)
}
} catch (error) {
console.log(error)
}
}

return defineConfig({
title: 'Koishi',
description: '创建跨平台、可扩展、高性能的机器人',

locales: {
'en-US': require('./en-US'),
'zh-CN': require('./zh-CN'),
...(isDev ? {
'zh-TW': require('./zh-TW'),
'de-DE': require('./de-DE'),
'fr-FR': require('./fr-FR'),
'ja-JP': require('./ja-JP'),
'ru-RU': require('./ru-RU'),
} : {}),
},
},

sitemap: {
hostname: 'https://koishi.chat',
},
themeConfig: {
indexName: 'docs',
logo: '/logo.png',

socialLinks: {
github: 'https://github.com/koishijs/koishi',
},
},

sitemap: {
hostname: 'https://koishi.chat',
},

vite: {
optimizeDeps: {
include: ['xss'],
vite: {
optimizeDeps: {
include: ['xss'],
},
},
},
})
})
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@koishijs/components": "^1.3.3",
"@koishijs/core": "^4.14.1",
"@koishijs/market": "^4.1.3",
"@koishijs/registry": "^6.0.2",
"@koishijs/registry": "^6.0.3",
"@koishijs/vitepress": "^2.3.0",
"@types/node": "^20.4.2",
"@types/spark-md5": "^3.0.2",
Expand Down
5 changes: 3 additions & 2 deletions zh-CN/cookbook/online.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ export default plugin
```json title=package.json
{
"main": "lib/node/index.cjs",
"typings": "lib/index.d.ts",
"types": "lib/index.d.ts",
"exports": {
".": {
"node": "./lib/node/index.cjs",
"browser": "./lib/browser/index.mjs"
"browser": "./lib/browser/index.mjs",
"types": "./lib/index.d.ts"
},
"./shared": {
"require": "./lib/shared/index.cjs",
Expand Down
2 changes: 1 addition & 1 deletion zh-CN/guide/develop/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 安装 Node.js

Koishi 需要 [Node.js](https://nodejs.org/) (最低 v14,推荐使用 LTS) 运行环境,你需要自己安装它。
Koishi 需要 [Node.js](https://nodejs.org/) (最低 v16,推荐使用 LTS) 运行环境,你需要自己安装它。

### 下载安装包

Expand Down
2 changes: 1 addition & 1 deletion zh-CN/manual/starter/boilerplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ next:

## 安装 Node.js

Koishi 需要 [Node.js](https://nodejs.org/) (最低 v14,推荐使用 LTS) 运行环境,你需要自己安装它。
Koishi 需要 [Node.js](https://nodejs.org/) (最低 v16,推荐使用 LTS) 运行环境,你需要自己安装它。

### 下载安装包

Expand Down
2 changes: 1 addition & 1 deletion zh-CN/manual/starter/direct.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ next:
Koishi 本身使用 TypeScript 编写,因此我们推荐你使用 TypeScript 来进行 Koishi 开发。在接下来的文档中,我们将统一使用 TypeScript 作为示例代码。如果你想编写原生 JavaScript 或使用其他方言,可以在示例代码的基础上自行修改。
:::

Koishi 需要 [Node.js](https://nodejs.org/) (最低 v14,推荐使用 LTS) 运行环境,你需要自己安装它。这里我们假定你已经安装完成了。
Koishi 需要 [Node.js](https://nodejs.org/) (最低 v16,推荐使用 LTS) 运行环境,你需要自己安装它。这里我们假定你已经安装完成了。

首先初始化你的机器人目录并安装 Koishi 和所需的插件 (这里以官方插件 console, sandbox 和 echo 为例):

Expand Down

0 comments on commit 2e3e9d0

Please sign in to comment.