Skip to content

Commit

Permalink
feat: 📃update docs style
Browse files Browse the repository at this point in the history
  • Loading branch information
nailiable committed Oct 26, 2024
1 parent df77f97 commit 40797cb
Show file tree
Hide file tree
Showing 8 changed files with 524 additions and 36 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions docs/.vitepress/cache/deps/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"hash": "8d1488a8",
"hash": "1cdb2662",
"configHash": "6bb8cdf2",
"lockfileHash": "efbac7d7",
"browserHash": "7fa9f6be",
"lockfileHash": "f84ebc7b",
"browserHash": "32d6c109",
"optimized": {
"vue": {
"src": "../../../../node_modules/.pnpm/[email protected][email protected]/node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "f29975de",
"fileHash": "2029d163",
"needsInterop": false
},
"vitepress > @vue/devtools-api": {
"src": "../../../../node_modules/.pnpm/@[email protected]/node_modules/@vue/devtools-api/dist/index.js",
"file": "vitepress___@vue_devtools-api.js",
"fileHash": "f1167e4b",
"fileHash": "02f5f3ec",
"needsInterop": false
},
"vitepress > @vueuse/core": {
"src": "../../../../node_modules/.pnpm/@[email protected][email protected][email protected]_/node_modules/@vueuse/core/index.mjs",
"file": "vitepress___@vueuse_core.js",
"fileHash": "50a3d5c0",
"fileHash": "b0f77eba",
"needsInterop": false
},
"@shikijs/vitepress-twoslash/client": {
"src": "../../../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@shikijs/vitepress-twoslash/dist/client.mjs",
"file": "@shikijs_vitepress-twoslash_client.js",
"fileHash": "bcf092d4",
"fileHash": "bb186c04",
"needsInterop": false
}
},
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export default defineConfig({
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' },
{ icon: 'npm', link: 'https://www.npmjs.com/org/nailyjs' },
{ icon: 'github', link: 'https://github.com/nailyjs/core' },
],
},

Expand Down
61 changes: 48 additions & 13 deletions docs/.vitepress/theme/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,55 @@
* Custom CSS
* -------------------------------------------------------------------------- */

:root {
--vp-nav-bg-color: transparent;
--vp-local-nav-bg-color: transparent;
--vp-sidebar-bg-color: transparent;
}
html.dark {
.Layout {
--overlay-blurple: #7a5cd633;
--overlay-red: #ff000033;
--overlay-green: #00ff0033;
background: linear-gradient(215deg, var(--overlay-blurple), transparent 90%), radial-gradient(var(--overlay-red), transparent 40%) no-repeat -60vw -40vh / 105vw 200vh, radial-gradient(var(--overlay-green), transparent 65%) no-repeat 50% calc(100% + 20rem) / 80rem 30rem;
}

body {
background-color: hsl(224deg 19.56% 4.66%)
}

&:root {
--vp-nav-bg-color: transparent;
--vp-local-nav-bg-color: transparent;
--vp-sidebar-bg-color: transparent;
--vp-c-bg-elv: #3c1b33;
}

.dark body {
background-color: hsl(224deg 19.56% 4.66%)
}
@media (max-width: 1280px) {
.VPLocalNav.has-sidebar {
border-bottom: none !important;
}
}

.dark .Layout {
--overlay-blurple: #7a5cd633;
--overlay-red: #ff000033;
--overlay-green: #00ff0033;
background: linear-gradient(215deg, var(--overlay-blurple), transparent 90%), radial-gradient(var(--overlay-red), transparent 40%) no-repeat -60vw -40vh / 105vw 200vh, radial-gradient(var(--overlay-green), transparent 65%) no-repeat 50% calc(100% + 20rem) / 80rem 30rem;
.VPNavBar, .VPLocalNav.has-sidebar {
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
}

.VPLocalNav.has-sidebar .container {
border-bottom: 1px solid var(--vp-c-gutter);
}

.VPNavScreen {
background-color: transparent;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
}

aside {
border-right: 1px solid var(--vp-c-gutter);

&.open {
@media (max-width: 960px) {
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: #191d466e;
}
}
}
}
3 changes: 3 additions & 0 deletions docs/en/rpc-guide/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RPC Guide

> Wait to be translated
40 changes: 39 additions & 1 deletion docs/rpc-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pnpm add unplugin-rpc @nailyjs/rpc @nailyjs/ioc @nailyjs/backend

```typescript twoslash
import Rpc from 'unplugin-rpc/vite'
import { defineConfig } from 'vite'
import { defineConfig, type UserConfig } from 'vite'

export default defineConfig({
plugins: [
Expand All @@ -95,11 +95,49 @@ export default defineConfig({
entryExport: 'app',
// 后端入口文件的路径,默认是`./backend/main.ts`。
serverEntry: './backend/main.ts',
// 当后端使用`vite build`命令打包时,会采用下面的配置。
// 这个配置项会与默认的配置项进行合并
// 默认配置项可以在`unplugin-rpc`的`src/index.ts`下的`buildServer`函数中找到。
viteOptions: {},
// 是否在vite关闭时打包后端代码,默认是`true`。
buildOnViteCloseBundle: true,
}),
],
})
```

::: warning 关于`buildOnViteCloseBundle`

有时候你得调整一下你的配置,比如当你在使用`vite-ssg`打包项目的时候,你可能需要将这个配置项设置为`false`,然后在`vite-ssg`打包完成的`ssgOptions.onFinished`回调中手动build后端代码。此时你可以在`vite.config.ts`中这样配置:

```typescript twoslash
/// <reference types="vite-ssg" />

import Rpc from 'unplugin-rpc/vite'
import { defineConfig } from 'vite'
// 导入这个函数,这个函数执行的时候就会去build后端的代码
import { buildServer } from 'unplugin-rpc'

export default defineConfig({
plugins: [
Rpc({
buildOnViteCloseBundle: false,
// ... 其他配置
})
],

// 在vite-ssg打包完成后,手动调用buildServer函数来build后端代码
ssgOptions: {
async onFinished() {
await buildServer()
}
}
})
```

你可以参考[vitesse-naily](https://github.com/nailyjs/vitesse-naily/blob/main/vite.config.ts)`vite.config.ts`文件,看看如何配置`vite-ssg`支持。
:::

你可以看到这个插件的配置文件中定义了`entryExport``serverEntry`,所以你得在项目根目录创建`./backend/main.ts`文件,填入如下内容:

```typescript twoslash
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"unocss": "^0.63.6",
"unplugin-swc": "^1.5.1",
"vite": "^5.4.2",
"vite-ssg": "^0.23.8",
"vitepress": "^1.4.1",
"vitest": "^2.1.2"
},
Expand Down
Loading

0 comments on commit 40797cb

Please sign in to comment.