Skip to content

Commit 58492db

Browse files
committed
改用 algolia 搜索
1 parent daa2a0d commit 58492db

File tree

4 files changed

+115
-19
lines changed

4 files changed

+115
-19
lines changed

.github/workflows/docsearch.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: docsearch
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
algolia:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Get the content of docsearch.json as config
15+
id: algolia_config
16+
run: echo "::set-output name=config::$(cat docsearch.json | jq -r tostring)"
17+
18+
- name: Run algolia/docsearch-scraper image
19+
env:
20+
APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
21+
API_KEY: ${{ secrets.API_KEY }}
22+
CONFIG: ${{ steps.algolia_config.outputs.config }}
23+
run: |
24+
docker run \
25+
--env APPLICATION_ID=${APPLICATION_ID} \
26+
--env API_KEY=${API_KEY} \
27+
--env "CONFIG=${CONFIG}" \
28+
algolia/docsearch-scraper

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# SecRandom 文档
22

3-
使用 VitePress 搭建
3+
使用 VitePress 搭建,Netlify 部署
4+
5+
[![Netlify Status](https://api.netlify.com/api/v1/badges/f31b1cc4-0fdf-45fd-96f2-ef92ec108fde/deploy-status)](https://app.netlify.com/projects/secrandom/deploys)
46

57
## 快速开始
68
- 环境要求
@@ -23,17 +25,16 @@
2325
- 预览生产版本
2426
```bash
2527
npm run docs:preview
28+
```
2629
- 内容编写指南
2730
- 所有文档使用 Markdown 格式编写
2831
- 在 docs 目录下创建新的 .md 文件即可自动生成对应页面
2932
- 使用 Frontmatter 配置页面元数据:
3033
-`/docs/.vitepress/config.mts` 中配置站点
3134

3235
## 贡献指南
33-
欢迎参与文档贡献:
34-
3536
- Fork 本项目
36-
- 创建新分支
37-
- 提交更改
38-
- 推送到分支
37+
- 修改并提交 commit
38+
- 推送到 main 分支或新建 dev 分支
3939
- 创建 Pull Request
40+
- 等待审核后合并

docs/.vitepress/config.mts

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,53 @@ export default defineConfig({
7878
],
7979

8080

81+
//Algolia搜索
8182
search: {
82-
provider: "local",
83+
provider: 'algolia',
8384
options: {
84-
translations: {
85-
button: {
86-
buttonText: "搜索文档",
87-
buttonAriaLabel: "搜索文档",
88-
},
89-
modal: {
90-
noResultsText: "没有找到结果",
91-
resetButtonTitle: "清除搜索条件",
92-
footer: {
93-
selectText: "选择",
94-
navigateText: "切换",
95-
closeText: "关闭",
85+
appId: 'O2GGTAX57F',
86+
apiKey: '59d5f4b8088ab3c4e3c436b0660b29d4',
87+
indexName: 'doc',
88+
locales: {
89+
root: {
90+
placeholder: '搜索文档',
91+
translations: {
92+
button: {
93+
buttonText: '搜索文档',
94+
buttonAriaLabel: '搜索文档'
95+
},
96+
modal: {
97+
searchBox: {
98+
resetButtonTitle: '清除查询条件',
99+
resetButtonAriaLabel: '清除查询条件',
100+
cancelButtonText: '取消',
101+
cancelButtonAriaLabel: '取消'
102+
},
103+
startScreen: {
104+
recentSearchesTitle: '搜索历史',
105+
noRecentSearchesText: '没有搜索历史',
106+
saveRecentSearchButtonTitle: '保存至搜索历史',
107+
removeRecentSearchButtonTitle: '从搜索历史中移除',
108+
favoriteSearchesTitle: '收藏',
109+
removeFavoriteSearchButtonTitle: '从收藏中移除'
110+
},
111+
errorScreen: {
112+
titleText: '无法获取结果',
113+
helpText: '你可能需要检查你的网络连接'
114+
},
115+
footer: {
116+
selectText: '选择',
117+
navigateText: '切换',
118+
closeText: '关闭',
119+
searchByText: '搜索提供者'
120+
},
121+
noResultsScreen: {
122+
noResultsText: '无法找到相关结果',
123+
suggestedQueryText: '你可以尝试查询',
124+
reportMissingResultsText: '你认为该查询应该有结果?',
125+
reportMissingResultsLinkText: '点击反馈'
126+
},
127+
},
96128
},
97129
},
98130
},

docsearch.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"index_name": "doc",
3+
"start_urls": [
4+
{
5+
"url": "https://secrandom.netlify.app",
6+
"selectors_key": ""
7+
}
8+
],
9+
"stop_urls": [],
10+
"selectors": {
11+
"default": {
12+
"lvl0": {
13+
"selector": "",
14+
"default_value": "我的文档"
15+
},
16+
"lvl1": ".content h1",
17+
"lvl2": ".content h2",
18+
"lvl3": ".content h3",
19+
"lvl4": ".content h4",
20+
"lvl5": ".content h5",
21+
"lvl6": ".content h6",
22+
"text": ".content p, .content li",
23+
"lang": {
24+
"selector": "/html/@lang",
25+
"type": "xpath",
26+
"global": true
27+
}
28+
}
29+
},
30+
"custom_settings": {
31+
"attributesForFaceting": [
32+
"lang"
33+
]
34+
}
35+
}

0 commit comments

Comments
 (0)