docs: add how to use fuse

This commit is contained in:
YunYouJun 2023-01-24 04:48:04 +08:00
parent de1bd6213f
commit 7ef8079d36
5 changed files with 62 additions and 2 deletions

View File

@ -4,7 +4,7 @@
"theme": "yun"
},
"scripts": {
"build": "npm run build:ssg && npm run rss",
"build": "npm run build:ssg && npm run rss && npm run fuse",
"build:spa": "valaxy build",
"build:ssg": "valaxy build --ssg",
"dev": "nodemon -w \"../../packages/valaxy/dist/*.cjs\" --exec \"valaxy .\"",

View File

@ -12,8 +12,10 @@ end: false
## Todo
- [ ] create-valaxy-theme: Script to generate theme template.
- [ ] create-valaxy-addon: Script to generate addon template.
- [ ] Debug component.
- [ ] local search
- [x] local search
- [ ] algolia search for valaxy-theme-press
## Dev

View File

@ -7,6 +7,57 @@ end: false
top: 99
---
## 搜索
### 本地搜索(基于 fuse.js
Valaxy 内置了基于 [fuse.js](https://fusejs.io/) 的离线搜索(须预先通过 `valaxy fuse` 构建生成本地缓存)。
> `valaxy fuse` 默认将 `fuse` 生成在 `dist` 目录下,如果你想在本地预览效果,你可以将 `dist/fuse-list.json` 拷贝至 `public/` 文件夹下。
#### 使用
```ts
// site.config.ts
import { defineSiteConfig } from 'valaxy'
export default defineSiteConfig({
search: {
enable: true,
// 设置类型为 Fuse
type: 'fuse',
},
})
```
- 在你的 `package.json` 中添加 fuse 生成脚本
```json {7,10}
{
"name": "yun-demo",
"valaxy": {
"theme": "yun"
},
"scripts": {
"build": "npm run build:ssg && npm run rss && npm run fuse",
"build:ssg": "valaxy build --ssg",
"fuse": "valaxy fuse",
"rss": "valaxy rss"
},
"dependencies": {
"valaxy": "latest",
"valaxy-theme-yun": "latest"
}
}
```
### Algolia 搜索
Algolia 是一个在线第三方搜索服务,您需要自行申请相关 ID 和 Secret。
> [DocSearch](https://docsearch.algolia.com/) 申请通常只接受技术文档。
Valaxy 提供了一个快速集成插件 [valaxy-addon-algolia](https://github.com/YunYouJun/valaxy/tree/main/packages/valaxy-addon-algolia)(目前仅支持 DocSearch
## 音乐播放器
> 基于 [Aplayer](https://github.com/DIYgod/APlayer) 与 [MetingJS](https://github.com/metowolf/MetingJS) 实现

View File

@ -1,3 +1,6 @@
# valaxy
fuse-list.json
# vite-ssg
.vite-ssg-dist
.vite-ssg-temp

View File

@ -2,6 +2,10 @@
[Algolia Search](https://www.algolia.com/) for [valaxy](https://valaxy.site).
目前仅支持 [DocSearch](https://docsearch.algolia.com/)。
> DocSearch 通常只接受技术文档的申请。
## Usage
```bash