diff --git a/.vscode/settings.json b/.vscode/settings.json index 0235cbb1..9a472acb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -56,6 +56,7 @@ "vue" ], "cSpell.words": [ + "acfun", "bilibili", "bumpp", "caniuse", diff --git a/docs/.vuepress/notes/zh/theme-guide.ts b/docs/.vuepress/notes/zh/theme-guide.ts index a032e7cd..eff3dc9b 100644 --- a/docs/.vuepress/notes/zh/theme-guide.ts +++ b/docs/.vuepress/notes/zh/theme-guide.ts @@ -109,6 +109,7 @@ export const themeGuide: ThemeNote = defineNoteConfig({ items: [ 'pdf', 'bilibili', + 'acfun', 'youtube', 'artplayer', 'audioReader', diff --git a/docs/.vuepress/theme.ts b/docs/.vuepress/theme.ts index 5c10202a..4aef1ed2 100644 --- a/docs/.vuepress/theme.ts +++ b/docs/.vuepress/theme.ts @@ -35,6 +35,7 @@ export const theme: Theme = plumeTheme({ imageSize: 'all', pdf: true, caniuse: true, + acfun: true, bilibili: true, youtube: true, artPlayer: true, diff --git a/docs/notes/theme/config/plugins/markdown-power.md b/docs/notes/theme/config/plugins/markdown-power.md index 614da741..c7a343b4 100644 --- a/docs/notes/theme/config/plugins/markdown-power.md +++ b/docs/notes/theme/config/plugins/markdown-power.md @@ -29,6 +29,7 @@ export default defineUserConfig({ // demo: true, // :::demo // pdf: true, // @[pdf](url) 嵌入 PDF 文件 // bilibili: true, // @[bilibili](bvid) 嵌入 bilibili 视频 + // acfun: true, // @[acfun](id) 嵌入 AcFun 视屏 // youtube: true, // @[youtube](id) 嵌入 youtube 视频 // codepen: true, // @[codepen](user/slash) 嵌入 codepen // replit: true, // @[replit](user/repl-name) 嵌入 Replit @@ -86,6 +87,18 @@ __语法:__ 请查看 [完整使用文档](../../guide/embed/bilibili.md) +### AcFun 视频 + +插件默认不启用该功能,你需要手动设置 `acfun` 为 `true` + +__语法:__ + +```md +@[acfun](id) +``` + +请查看 [完整使用文档](../../guide/embed/video/acfun.md) + ### youtube 视频 插件默认不启用该功能,你需要手动设置 `youtube` 为 `true` diff --git a/docs/notes/theme/guide/embed/acfun.md b/docs/notes/theme/guide/embed/acfun.md new file mode 100644 index 00000000..ba675d58 --- /dev/null +++ b/docs/notes/theme/guide/embed/acfun.md @@ -0,0 +1,62 @@ +--- +title: AcFun 视频 +icon: lets-icons:video-fill +createTime: 2025/06/28 10:57:45 +permalink: /guide/embed/video/acfun/ +badge: 新 +--- + +## 概述 + +主题提供了 嵌入 AcFun 视频 的功能。 + +该功能由 [vuepress-plugin-md-power](../../config/plugins/markdown-power.md) 提供支持。 + +## 配置 + +该功能默认不启用。你需要在主题配置中开启。 + +```ts title=".vuepress/config.ts" +export default defineUserConfig({ + theme: plumeTheme({ + markdown: { + acfun: true, // [!code ++] + }, + }) +}) +``` + +## 语法 + +简单的语法: + +```md +@[acfun](id) +``` + +更多选项: + +```md +@[acfun width="100%" height="400px" ratio="16:9"](id) +``` + +**选项说明:** + +- id: 视频 ID +- width: 视频宽度 +- height: 视频高度 +- ratio: 视频比例,默认 `16:9` + +## 示例 + +### 宽频视频 + +输入: + +```md +@[acfun](ac47431669) +``` + +输出: + +@[acfun](ac47431669) diff --git a/plugins/plugin-md-power/__test__/__snapshots__/acfunPlugin.spec.ts.snap b/plugins/plugin-md-power/__test__/__snapshots__/acfunPlugin.spec.ts.snap new file mode 100644 index 00000000..0a60e16a --- /dev/null +++ b/plugins/plugin-md-power/__test__/__snapshots__/acfunPlugin.spec.ts.snap @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`acfunPlugin > should not work 1`] = ` +"

@[acfun]xxx

+

@[ acfun]123456

+

@ acfun

+" +`; + +exports[`acfunPlugin > should work 1`] = `""`; diff --git a/plugins/plugin-md-power/__test__/__snapshots__/bilibiliPlugin.spec.ts.snap b/plugins/plugin-md-power/__test__/__snapshots__/bilibiliPlugin.spec.ts.snap index 5cc71d14..ea35bbda 100644 --- a/plugins/plugin-md-power/__test__/__snapshots__/bilibiliPlugin.spec.ts.snap +++ b/plugins/plugin-md-power/__test__/__snapshots__/bilibiliPlugin.spec.ts.snap @@ -1,10 +1,10 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`bilibiliPlugin > should not work 1`] = ` -"

@[bilibili]xxx

+"

@[bilibili]xxx

@[ bilibili]BV12345

@[bilibili](BV12345

" `; -exports[`bilibiliPlugin > should work 1`] = `""`; +exports[`bilibiliPlugin > should work 1`] = `""`; diff --git a/plugins/plugin-md-power/__test__/__snapshots__/youtubePlugin.spec.ts.snap b/plugins/plugin-md-power/__test__/__snapshots__/youtubePlugin.spec.ts.snap index 561a4d4c..b3e75672 100644 --- a/plugins/plugin-md-power/__test__/__snapshots__/youtubePlugin.spec.ts.snap +++ b/plugins/plugin-md-power/__test__/__snapshots__/youtubePlugin.spec.ts.snap @@ -1,10 +1,10 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`youtubePlugin > should not work 1`] = ` -"

@[youtube]xxx

+"

@[youtube]xxx

@[ youtube]123456

@ youtube

" `; -exports[`youtubePlugin > should work 1`] = `""`; +exports[`youtubePlugin > should work 1`] = `""`; diff --git a/plugins/plugin-md-power/__test__/acfunPlugin.spec.ts b/plugins/plugin-md-power/__test__/acfunPlugin.spec.ts new file mode 100644 index 00000000..0926b547 --- /dev/null +++ b/plugins/plugin-md-power/__test__/acfunPlugin.spec.ts @@ -0,0 +1,42 @@ +import MarkdownIt from 'markdown-it' +import { describe, expect, it } from 'vitest' +import { acfunPlugin } from '../src/node/embed/video/acfun.js' + +function createMarkdown() { + return MarkdownIt().use((md) => { + md.block.ruler.before('code', 'import_code', () => false) + md.renderer.rules.import_code = () => '' + }).use(acfunPlugin) +} + +describe('acfunPlugin', () => { + it('should work', () => { + const md = createMarkdown() + const code = `\ +@[acfun](123456) + +@[acfun title="test"](123456) + +@[acfun width="100%" height="600px"](123456) + +@[acfun width="100%" ratio="16:9"](123456) +` + + expect(md.render(code)).toMatchSnapshot() + }) + + it('should not work', () => { + const md = createMarkdown() + const code = `\ +@[acfun]() + +@[acfun]xxx + +@[ acfun]123456 + +@[ acfun](123456) +` + + expect(md.render(code)).toMatchSnapshot() + }) +}) diff --git a/plugins/plugin-md-power/src/client/components/Bilibili.vue b/plugins/plugin-md-power/src/client/components/Bilibili.vue deleted file mode 100644 index f72512c1..00000000 --- a/plugins/plugin-md-power/src/client/components/Bilibili.vue +++ /dev/null @@ -1,45 +0,0 @@ - - -