feat: add youtube video (#491)

This commit is contained in:
Laitron 2024-06-13 22:15:44 +08:00 committed by GitHub
parent c38e8abfc8
commit 6679dbd07b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 3 deletions

View File

@ -9,7 +9,7 @@
'use strict'; 'use strict';
module.exports = ctx => function (args) { module.exports = ctx => function (args) {
args = ctx.args.map(args, ['type', 'bilibili', 'ratio', 'width', 'autoplay'], ['src']) args = ctx.args.map(args, ['type', 'bilibili', 'youtube', 'ratio', 'width', 'autoplay'], ['src'])
if (args.width == null) { if (args.width == null) {
args.width = '100%' args.width = '100%'
} }
@ -20,8 +20,14 @@ module.exports = ctx => function (args) {
</div> </div>
` `
} }
return ` if (args.youtube) {
<div class="tag-plugin video" style="max-width:${args.width};"> return `<div class="tag-plugin video" style="aspect-ratio:${args.ratio || 16/9};max-width:${args.width};">
<iframe src="https://www.youtube.com/embed/${args.youtube}?rel=0&color=white&disablekb=1&playsinline=1&&rel=0&autoplay=${args.autoplay || '0'}; picture-in-picture="true" allowfullscreen="true" >
</iframe>
</div>
`
}
return `<div class="tag-plugin video" style="max-width:${args.width};">
<video controls preload> <video controls preload>
<source src="${args.src}" type="${args.type || 'video/mp4'}">Your browser does not support the video tag. <source src="${args.src}" type="${args.type || 'video/mp4'}">Your browser does not support the video tag.
</video> </video>