安装和基本介绍
注意
vuepress 2.x 不知道在哪一版 API 更改过大,导致本插件已无法正常使用,考虑后决定暂不适配 vuepress 2.x,待稳定后再做考虑。
注意
本插件适用于 Vuepress 1.x 和 vuepress 2.x (测试中),其他版本未作测试
提示
本插件文档看似繁琐复杂,其实是最简单的,能给用户最大的自定义范围。
# 简介
vuepress-plugin-smplayer (opens new window) 是一个能在 Vuepress 中快速插入媒体标签的插件,目前支持的标签和平台有(持续开发中):
- Aplayer (opens new window)
- MetingJS (opens new window)
- Dplayer (opens new window)
- 哔哩哔哩 (opens new window)
- 西瓜视频 (opens new window)
- YouTube
- ArtPlayer (opens new window)
- xgplayer (opens new window)
# 特点
- 有多种播放器和视频平台可供选择
- 100% TypeScript 开发,享受类型约束带来的便利
- 兼容性好,配置方式灵活
- ...
# 使用
vuepress-plugin-smplayer 插件和其他 Vuepress 插件使用方法类似,诸如 如何启用一个插件 之类的共性问题就不再赘述了,只说 vuepress-plugin-smplayer 相关的。
# 安装
yarn add vuepress-plugin-smplayer@1
1
pnpm install vuepress-plugin-smplayer@1
1
npm install vuepress-plugin-smplayer@1
1
yarn add vuepress-plugin-smplayer@2
1
pnpm install vuepress-plugin-smplayer@2
1
npm install vuepress-plugin-smplayer@2
1
// Make sure to add code blocks to your code group
# 配置
注意
这一部分会随着插件持续更新,如无特殊说明,最新文档对应最新版插件。插件目前仍在开发阶段,不排除接口变更的可能性。
注意
默认情况下无需额外配置,如有需要,请按需配置。
// .vuepress/config.ts
import { defineConfig } from "vuepress/config";
import type { SmPlayerPluginOption } from "vuepress-plugin-smplayer/types";
export default defineConfig({
plugins: [
[
"smplayer",
{
/* 配置项见详细文档 */
} as SmPlayerPluginOption,
],
],
});
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
注意
上述代码仅仅为一个示例,详情见相关主题文档。
注意
使用 config.ts
配置时,建议使用 import type { SmPlayerPluginOption } from "vuepress-plugin-smplayer/types";
享受类型约束带来的便利。
// .vuepress/config.js
module.exports = {
plugins: [
[
"smplayer",
{
/* 配置项见详细文档 */
},
],
],
};
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
// .vuepress/config.js
module.exports = {
plugins: [
[
require("vuepress-plugin-smplayer")({
/* 配置项见详细文档 */
}),
],
],
};
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
// Make sure to add code blocks to your code group
# 建议
- 建议配置
shouldPrefetch: () => false
- 建议使用
config.ts
作为配置文件,可享受类型约束带来的便利
# FAQ
详见 FAQ
# 反馈
注意
插件中部分代码是由 Copilot 自动生成,未经严格测试,如发现问题请及时反馈。
上次更新: 10/4/2022, 11:21:17 PM