📝 Add introduce for supported module

This commit is contained in:
zhengyi 2024-01-01 14:41:19 +08:00
parent 23c24a6d8f
commit da98bbe635
8 changed files with 150 additions and 19 deletions

View File

@ -42,6 +42,13 @@ renderHalo方法会返回解析后的html结构。renderHalo的参数与返回
function renderHalo(content: string, cdn: string): string;
```
## 语法参考
- [语法介绍](doc/general.md)
- [Tips组件](doc/tips.md)
- [Git组件](doc/git.md)
- [资源组件](doc/drive.md)
## 开发
1. 安装依赖

BIN
doc/assets/drive.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
doc/assets/git.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
doc/assets/tips.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

46
doc/drive.md Normal file
View File

@ -0,0 +1,46 @@
# 资源分享组件
资源分享组件可以帮助用户生成一个分享展示的模块,它会包含资源平台、资源内容、链接按钮和提取码的信息。
当前资源平台支持百度网盘和阿里网盘的显示。
## 语法
```markdown
drive:<platform>
name: <title>
link: <link>
password: <password>
```
- `name`: 展示的资源标题
- `link`: 跳转到资源的链接
- `password`: 可选,资源提取码
## platform
当前支持的平台:
- `baidu`: 百度网盘
- `ali`: 阿里云盘
平台实际上只是一个icon和标题的组合并不会影响资源的访问如果您不介意您可以在下方的配置中填写任意的链接。
## 示例
- 阿里云盘
```markdown
drive:ali
name: 网站资源集合
link: https://www.ali.com/
```
- 百度网盘
```markdown
drive:baidu
name: 网站资源集合
link: https://www.baidu.com/
password: 1234
```

29
doc/general.md Normal file
View File

@ -0,0 +1,29 @@
# 语法设计
## 类型标识
解析器使用输入文本的第一行来标识渲染的类型,当前支持下面几种类型:
- `tips` 提供多彩的提示组件
- `git` 提供Git仓库信息的组件
- `drive` 提供资源下载的组件
渲染类型标识可以在后方加入一些子类型或配置信息,格式如下:
```plaintext
<type>:<option | sub_type>
```
例如tips组件在后方标识了子类型如`tips:danger`则表示使用`tips`解析器解析为danger样式。
git组件则在后方标识了一组配置如`git:[@github/justice2001/halo-plugin-vditor]`
具体的行为可以由解析器来自定义。
## 内容
从第二行起至最后一行,均为内容部分,这一部分会被作为整体传入到解析器中,解析器可以根据需要来设计语法。
如`drive`组件则在此处处理附加的长配置信息。
而`tips`则会将此部分内容解析为html附加到内容中。

55
doc/git.md Normal file
View File

@ -0,0 +1,55 @@
# Git组件
![Git Module](assets/git.png)
Git组件为用户提供了在页面中嵌入git仓库的解决方案常用的使用场景是为开源项目开发者发布文章时可以将此Git仓库快速嵌入到文章之中。
当前git组件支持的平台包括
- `GitHub`: 无需配置URL
- `Gitee`: 无需配置URL
## 语法
```markdown
git:[<url>@<platform>/<owner>/<repository>]
```
### url
URL是平台的URL当前为保留字段为后续加入自建Gitlab和Gitea做支持准备。如果您使用的是官方的平台则无需填写此字段。
URL示例`https://gitlab.example.com/`
### platform
标识平台类型解析器会根据不同的平台选择不同的API和返回值处理方式。当前解析器支持下列平台
- `Github`:仅支持官方平台
- `Gitee`:仅支持官方平台
### owner
仓库所有者
### repository
仓库名称
## 示例
- GitHub平台
```markdown
git:[@github/justice2001/halo-plugin-vditor]
```
- Gitee平台
```markdown
git:[@gitee/blossom-editor/blossom]
```
- Gitea平台当前未实现
```markdown
git:[https://git.mczhengyi.top@gitea/zhengyi/halo-plugin-vidtor]
```

View File

@ -1,27 +1,21 @@
# Tips组件
使用`tips:[type]`来启用type支持`info`, `success`, `danger`, `warn`四种类型
![Tips Module](assets/tips.png)
Tips为用户提供了多彩的提示组件支持五种类型`default`、`danger`、`success`、`warn`、`info`。
同时内容支持渲染HTML内容。
## 语法
```markdown
tips:<type>
<content>
```
tips:info
Here is success
---
tips:success
Here is success
---
## 示例
```markdown
tips:danger
Here is danger
---
tips:warn
Here is Warning
This is a Danger type tips
```