Skip to content

Commit

Permalink
setup mixins (not used)
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 24, 2023
1 parent aeda1c2 commit 16067e7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.WORKFLOW_TOKEN }}
external_repository: koishijs/docs-deploy
publish_branch: dist
publish_dir: .vitepress/dist
force_orphan: true
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dist/
external/
ecosystem/
.data
.temp
.vitepress/cache
Expand Down
1 change: 1 addition & 0 deletions .vitepress/config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.ts
24 changes: 13 additions & 11 deletions .vitepress/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { defineConfig } from '@koishijs/vitepress'
import { resolve } from 'path'
import { mkdir, rm, symlink } from 'fs/promises'
import { cp, mkdir, rm } from 'fs/promises'
import { external } from './mixin'
import mixins from './output'

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

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 })
await mkdir(resolve(__dirname, '../..', locale, 'ecosystem'), { recursive: true })
}

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

Expand All @@ -43,6 +43,8 @@ export default async () => {
} : {}),
},

mixins: await mixins(),

themeConfig: {
indexName: 'docs',
logo: '/logo.png',
Expand Down
14 changes: 14 additions & 0 deletions .vitepress/config/mixin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { writeFile } from 'fs/promises'
import { resolve } from 'path'

export const external = [] // ['assets', 'cache', 'common']

async function main() {
await writeFile(resolve(__dirname, 'output.ts'), `export default async () => ({\n${external.map(name => {
return ` ["/ecosystem/${name}"]: await (await import("${require.resolve(`@root/${name}/docs/.vitepress/config`)}")).default,`
}).join('\n')}\n})\n`)
}

if (require.main === module) {
main()
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"author": "Shigma <[email protected]>",
"license": "MIT",
"scripts": {
"dev": "vitepress dev . --port 8514 --open",
"mixin": "node -r esbuild-register .vitepress/config/mixin.ts",
"dev": "yarn mixin & vitepress dev . --port 8514 --open",
"serve": "vitepress serve . --port 8514 --open",
"build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vitepress build ."
"build": "yarn mixin & cross-env NODE_OPTIONS=--max-old-space-size=8192 vitepress build ."
},
"devDependencies": {
"@koishijs/components": "^1.3.4",
"@koishijs/core": "^4.14.2",
"@koishijs/market": "^4.1.3",
"@koishijs/registry": "^6.0.3",
"@koishijs/vitepress": "^2.3.0",
"@koishijs/vitepress": "^3.0.0",
"@types/node": "^20.4.2",
"@types/spark-md5": "^3.0.2",
"cross-env": "^7.0.3",
Expand Down

0 comments on commit 16067e7

Please sign in to comment.