Skip to content

Commit

Permalink
docs: move vitepress to root
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinhuish committed Oct 17, 2024
1 parent a6ec33e commit dde5255
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 90 deletions.
File renamed without changes.
31 changes: 19 additions & 12 deletions src/.vitepress/config.ts → .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { dirname, join } from 'node:path';
import fg from 'fast-glob';
import { defineConfig } from 'vitepress';

const files = await fg('*', {
onlyDirectories: true,
cwd: './src',
ignore: [
'public',
'apis',
'guide',
],
const files = await fg('**/*.md', {
cwd: join(__dirname, '..', 'src'),
});

const dirs = [...new Set(files.map(f => dirname(f)).filter(d => d !== '.' && d !== '..'))];

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: 'UniUse',
description: 'uni-app (vue3) 组合式工具集。',
lang: 'zh-CN',
srcDir: '.',
srcExclude: ['!(docs|src)/**'],
rewrites: {
'docs/:name.md': ':name.md',
'docs/:doc/:name.md': ':doc/:name.md',
'src/index.md': 'apis.md',
'src/:pkg/:name.md': ':pkg/:name.md',
},

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

Expand All @@ -36,7 +42,7 @@ export default defineConfig({
},
{
text: '注意事项',
link: '/guide/notice/',
link: '/guide/notice',
},
{
text: '更新日志',
Expand All @@ -61,9 +67,9 @@ export default defineConfig({
},
{
text: 'API',
items: files.map(file => ({
text: file,
link: `/${file}/`,
items: dirs.map(dir => ({
text: dir,
link: `/${dir}/`,
})),
},
],
Expand Down Expand Up @@ -132,4 +138,5 @@ export default defineConfig({
{ icon: 'github', link: 'https://github.com/uni-helper/uni-use' },
],
},

});
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ npm install @uni-helper/uni-use @vueuse/core@9

## 使用

详情请看 [`uni-use`函数列表](./src/apis/index.md)
详情请看 [`uni-use`函数列表](./src/index.md)

## 其它

Expand Down
2 changes: 1 addition & 1 deletion src/guide/index.md → docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tryOnLoad(() => {
});
```

其它详情请查看所有 [API](../apis/index.md)
其它详情请查看所有 [API](/apis.md)

### `unplugin-auto-import` 结合使用

Expand Down
File renamed without changes.
31 changes: 31 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
layout: home

hero:
name: UniUse
text: uni-app 组合式工具集
tagline: 为 uni-app 量身打造的组合式工具集
image:
src: /logo.png
alt: UniUse
actions:
- theme: brand
text: 开始
link: /guide/
- theme: alt
text: API 集合
link: /apis

features:
- icon: 🎛
title: 功能丰富
details: 提供了丰富的功能,封装了 uni-app 中常用的功能。
- icon: 💚
title: 开箱即用
details: 开箱即用的支持了 uni-app Vue3 的 Composition API。
- icon: 🦾
title: 类型安全
details: 所有函数都支持 TS 类型推导,无需手动标注类型
---

<HomeTeam />
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"prepublishOnly": "pnpm run build",
"release": "pnpm install && pnpm run lint && bumpp",
"test": "vitest",
"docs:dev": "vitepress dev src",
"docs:build": "vitepress build src",
"docs:preview": "vitepress preview src"
"docs:dev": "vitepress dev",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview"
},
"peerDependencies": {
"@vueuse/core": "^9.0.0 || ^10.0.0",
Expand Down
File renamed without changes
39 changes: 0 additions & 39 deletions src/apis/index.md

This file was deleted.

68 changes: 38 additions & 30 deletions src/index.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
---
layout: home
# 函数列表

hero:
name: UniUse
text: uni-app 组合式工具集
tagline: 为 uni-app 量身打造的组合式工具集
image:
src: /logo.png
alt: UniUse
actions:
- theme: brand
text: 开始
link: /guide/
- theme: alt
text: API 集合
link: /apis/

features:
- icon: 🎛
title: 功能丰富
details: 提供了丰富的功能,封装了 uni-app 中常用的功能。
- icon: 💚
title: 开箱即用
details: 开箱即用的支持了 uni-app Vue3 的 Composition API。
- icon: 🦾
title: 类型安全
details: 所有函数都支持 TS 类型推导,无需手动标注类型
---

<HomeTeam />
- [tryOnBackPress](./tryOnBackPress/index.md)
- [tryOnHide](./tryOnHide/index.md)
- [tryOnInit](./tryOnInit/index.md)
- [tryOnLoad](./tryOnLoad/index.md)
- [tryOnReady](./tryOnReady/index.md)
- [tryOnScopeDispose](./tryOnScopeDispose/index.md)
- [tryOnShow](./tryOnShow/index.md)
- [tryOnUnload](./tryOnUnload/index.md)
- [useActionSheet](./useActionSheet/index.md)
- [useClipboardData](./useClipboardData/index.md)
- [useDownloadFile](./useDownloadFile/index.md)
- [useGlobalData](./useGlobalData/index.md)
- [useInterceptor](./useInterceptor/index.md)
- [useLoading](./useLoading/index.md)
- [useModal](./useModal/index.md)
- [useNetwork](./useNetwork/index.md)
- [useOnline](./useOnline/index.md)
- [usePage](./usePage/index.md)
- [usePages](./usePages/index.md)
- [usePageScroll](./usePageScroll/index.md)
- [usePreferredDark](./usePreferredDark/index.md)
- [usePreferredLanguage](./usePreferredLanguage/index.md)
- [usePrevPage](./usePrevPage/index.md)
- [usePrevRoute](./usePrevRoute/index.md)
- [useProvider](./useProvider/index.md)
- [useRequest](./useRequest/index.md)
- [useRoute](./useRoute/index.md)
- [useRouter](./useRouter/index.md)
- [useScanCode](./useScanCode/index.md)
- [useScreenBrightness](./useScreenBrightness/index.md)
- [useSelectorQuery](./useSelectorQuery/index.md)
- [useSocket](./useSocket/index.md)
- [useStorage](./useStorage/index.md)
- [useStorageSync](./useStorageSync/index.md)
- [useToast](./useToast/index.md)
- [useUploadFile](./useUploadFile/index.md)
- [useVisible](./useVisible/index.md)
2 changes: 1 addition & 1 deletion src/useStorage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ UNIAPP官网文档: <https://uniapp.dcloud.net.cn/api/storage/storage.html>

**注意,这是异步操作,赋值后并不会马上写入storage**

**如果需要同步操作,请使用[`useStorageSync`](../useStorageSync/readme.md)**
**如果需要同步操作,请使用[`useStorageSync`](../useStorageSync/index.md)**

```typescript
import { useStorage } from '@uni-helper/uni-use';
Expand Down
2 changes: 1 addition & 1 deletion src/useStorageAsync/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ UNIAPP官网文档: <https://uniapp.dcloud.net.cn/api/storage/storage.html>

- 这是异步操作,赋值后,ref 的值会生效,但并不会马上写入storage
- 和 uni 的原生 getStorageSync 混用的情况下,有可能会导致 getStorageSync 读取不到值。
- 如需和 uni 的原生 storage 操作混用,或需要同步操作,请使用[`useStorageSync`](../useStorageSync/readme.md)
- 如需和 uni 的原生 storage 操作混用,或需要同步操作,请使用[`useStorageSync`](../useStorageSync/index.md)

```typescript
import { useStorageAsync } from '@uni-helper/uni-use';
Expand Down
4 changes: 2 additions & 2 deletions src/useStorageSync/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ UNIAPP官网文档: <https://uniapp.dcloud.net.cn/api/storage/storage.html>
**注意:**

- 这是同步操作,赋值后会立即写入storage,直到写入结束前会一直阻塞线程
- 如果需要非阻塞,请使用[`useStorage`](../useStorage/readme.md)
- 如无须使用 uni 原生的 storage 操作,建议使用异步 [`useStorage`](../useStorage/readme.md)
- 如果需要非阻塞,请使用[`useStorage`](../useStorage/index.md)
- 如无须使用 uni 原生的 storage 操作,建议使用异步 [`useStorage`](../useStorage/index.md)

```typescript
import { useStorageSync } from '@uni-helper/uni-use';
Expand Down

0 comments on commit dde5255

Please sign in to comment.