Skip to content

Commit e1dbef5

Browse files
committed
docs(ui): added details when using @nolebase/ui
Signed-off-by: Neko Ayaka <neko@ayaka.moe>
1 parent f268e3f commit e1dbef5

2 files changed

Lines changed: 148 additions & 2 deletions

File tree

docs/pages/en/ui/index.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,86 @@
22
import { NuButton } from '@nolebase/ui'
33
</script>
44

5-
# UI Components
5+
# UI Components <Badge type="danger" text="Alpha" />
6+
7+
::: danger 🛑 This package is in Alpha stage.
8+
This package is still in the Alpha stage, and it is not recommended to use it in production. The API may change in the future, and there may be bugs in the current version. Please use it with caution.
9+
:::
610

711
::: warning 🚧 Constructing
812
Nice to meet you! But sorry, this page is still under construction. If you don’t find the information you are interested in, you can first find the content you are interested in in the navigation in the sidebar to start reading.
913
:::
1014

15+
## How to use
16+
17+
::: tip 🙋 Before install
18+
19+
Currently `@nolebase/ui` is still under development, and will be used by other [Nolebase Integrations](https://nolebase-integrations.ayaka.io) components now (such as [`vitepress-plugin-git-changelog`](/pages/en/integrations/vitepress-plugin-git-changelog/)). And those components and integrations of [Nolebase Integrations](https://nolebase-integrations.ayaka.io) will configure the needed options and settings to bundle and transform the underlying dependencies.
20+
21+
Therefore, if you would ever want to install `@nolebase/ui` as one of your dependencies, you would need to configure a few configurations before proceeding:
22+
23+
#### 1. Additional configurations for Vite
24+
25+
##### 1.1 For users who imported `<NuLazyTeleportRiveCanvas />` component
26+
27+
Since `<NuLazyTeleportRiveCanvas />` depends on `@rive-app/canvas`. If you also use Vite as your bundler, you will need to add the following configurations to your `vite.config.ts` file like this:
28+
29+
```typescript
30+
export default defineConfig(() => {
31+
return {
32+
optimizeDeps: { // [!code ++]
33+
include: [ // [!code ++]
34+
// Add this line to your vite.config.ts's optimizeDeps.include array // [!code ++]
35+
'@nolebase/ui @rive-app/canvas', // [!code ++]
36+
], // [!code ++]
37+
}, // [!code ++]
38+
}
39+
})
40+
```
41+
42+
For more information about why configure this, please refer to the [Dep Optimization Options | Vite](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude) documentation.
43+
44+
##### 1.2 For users who imported VitePress related components
45+
46+
If you are using VitePress, and imported components relies on VitePress, you will need to add the following configurations to your `vite.config.ts` file like this:
47+
48+
```typescript
49+
export default defineConfig(() => {
50+
return {
51+
ssr: { // [!code ++]
52+
noExternal: [ // [!code ++]
53+
// Add this line to your vite.config.ts's ssr.noExternal array // [!code ++]
54+
'@nolebase/ui', // [!code ++]
55+
], // [!code ++]
56+
}, // [!code ++]
57+
}
58+
})
59+
```
60+
61+
For more information about why configure this, please refer to the [Server-Side Rendering | Vite](https://vitejs.dev/guide/ssr.html#ssr-externals) documentation.
62+
63+
:::
64+
65+
### Installation
66+
67+
You can install `@nolebase/ui` as one of your Vue or VitePress project dependencies with the following command:
68+
69+
::: code-group
70+
71+
```shell [pnpm]
72+
pnpm add @nolebase/ui -D
73+
```
74+
75+
```shell [npm]
76+
npm install @nolebase/ui -D
77+
```
78+
79+
```shell [yarn]
80+
yarn add @nolebase/ui -D
81+
```
82+
83+
:::
84+
1185
## Buttons
1286

1387
<div>

docs/pages/zh-CN/ui/index.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,84 @@
22
import { NuButton } from '@nolebase/ui'
33
</script>
44

5-
# UI 组件
5+
# UI 组件 <Badge type="danger" text="Alpha 测试" />
6+
7+
::: danger 🛑 此包仍处于 Alpha 测试阶段
8+
此包仍处于 Alpha 测试阶段,不建议在生产中使用。未来 API 可能会发生变化,当前版本可能存在错误。请谨慎使用。
9+
:::
610

711
::: warning 🚧 施工中
812
很高兴见到你!但很抱歉,这个页面还在施工中,如果没有找到你感兴趣的信息,你可以先在侧边栏的导航中寻找你感兴趣的内容来开始阅读
913
:::
1014

15+
## 如何开始
16+
17+
::: tip 🙋 安装前须知
18+
19+
目前 `@nolebase/ui` 仍在开发中,将被其他 [Nolebase Integrations](https://nolebase-integrations.ayaka.io) 组件使用(例如 [`vitepress-plugin-git-changelog`](/pages/en/integrations/vitepress-plugin-git-changelog/)),而这些 [Nolebase Integrations](https://nolebase-integrations.ayaka.io) 组件都会自动帮忙配置好依赖解析和依赖打包等复杂操作。如果你想把 `@nolebase/ui` 作为你的依赖项之一来安装并使用,就需要仿照其他 [Nolebase Integrations](https://nolebase-integrations.ayaka.io) 组件,对 Vite 进行配置:
20+
21+
#### 1. 针对 Vite 的额外配置
22+
23+
##### 1.1 对于导入了 `<NuLazyTeleportRiveCanvas />` 组件的用户
24+
25+
由于 `<NuLazyTeleportRiveCanvas />` 底层依赖于 `@rive-app/canvas`,如果您也使用 Vite 作为打包器和开发环境服务器,则需要像这样在 `vite.config.ts` 文件中添加以下配置:
26+
27+
```typescript
28+
export default defineConfig(() => {
29+
return {
30+
optimizeDeps: { // [!code ++]
31+
include: [ // [!code ++]
32+
// 添加这一行到你的 vite.config.ts 的 optimizeDeps.include 数组中 // [!code ++]
33+
'@nolebase/ui @rive-app/canvas', // [!code ++]
34+
], // [!code ++]
35+
}, // [!code ++]
36+
}
37+
})
38+
```
39+
40+
有关为何要这样配置的更多信息,请参阅 [Dep Optimization Options | Vite](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude) 文档。
41+
42+
##### 1.2 针对导入 VitePress 相关组件的用户
43+
44+
如果您使用的是 VitePress,且导入的组件依赖于 VitePress,则需要像这样在 `vite.config.ts` 文件中添加以下配置:
45+
46+
```typescript
47+
export default defineConfig(() => {
48+
return {
49+
ssr: { // [!code ++]
50+
noExternal: [ // [!code ++]
51+
// 添加这一行到你的 vite.config.ts 的 ssr.noExternal 数组中 // [!code ++]
52+
'@nolebase/ui', // [!code ++]
53+
], // [!code ++]
54+
}, // [!code ++]
55+
}
56+
})
57+
```
58+
59+
有关为何如此配置的更多信息,请参阅 [Server-Side Rendering | Vite](https://vitejs.dev/guide/ssr.html#ssr-externals) 文档。
60+
61+
:::
62+
63+
### 安装
64+
65+
您可以使用以下命令将 `@nolebase/ui` 安装为 Vue 或 VitePress 项目的依赖项之一:
66+
67+
::: code-group
68+
69+
```shell [pnpm]
70+
pnpm add @nolebase/ui -D
71+
```
72+
73+
```shell [npm]
74+
npm install @nolebase/ui -D
75+
```
76+
77+
```shell [yarn]
78+
yarn add @nolebase/ui -D
79+
```
80+
81+
:::
82+
1183
## 按钮
1284

1385
<div>

0 commit comments

Comments
 (0)