[feat] tag-plugin: audio & video

This commit is contained in:
xaoxuu 2024-01-12 12:29:56 +08:00
parent fc345c17b3
commit 2ed4d21472
5 changed files with 58 additions and 1 deletions

View File

@ -39,4 +39,6 @@ hexo.extend.tag.register('poetry', require('./lib/poetry')(hexo), true)
hexo.extend.tag.register('quot', require('./lib/quot')(hexo))
hexo.extend.tag.register('hashtag', require('./lib/hashtag')(hexo))
hexo.extend.tag.register('okr', require('./lib/okr')(hexo), {ends: true})
hexo.extend.tag.register('audio', require('./lib/audio')(hexo))
hexo.extend.tag.register('video', require('./lib/video')(hexo))
// others

23
scripts/tags/lib/audio.js Normal file
View File

@ -0,0 +1,23 @@
/**
* audio.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
* 格式与官方标签插件一致使用空格分隔中括号内的是可选参数中括号不需要写出来
*
* {% audio src %}
*
*/
'use strict';
module.exports = ctx => function(args) {
args = ctx.args.map(args, ['type'], ['src'])
if (args.type == null) {
args.type = 'audio/mp3'
}
return `
<div class="tag-plugin video">
<audio controls preload>
<source src="${args.src}" type="${args.type}">Your browser does not support the audio tag.
</audio>
</div>
`
}

View File

@ -4,7 +4,7 @@
*
* 格式与官方标签插件一致使用空格分隔中括号内的是可选参数中括号不需要写出来
*
* {% md [src:url] %}
* {% md src %}
*
*/
'use strict'

23
scripts/tags/lib/video.js Normal file
View File

@ -0,0 +1,23 @@
/**
* video.js v1.0 | https://github.com/xaoxuu/hexo-theme-stellar/
* 格式与官方标签插件一致使用空格分隔中括号内的是可选参数中括号不需要写出来
*
* {% video src %}
*
*/
'use strict';
module.exports = ctx => function(args) {
args = ctx.args.map(args, ['type'], ['src'])
if (args.type == null) {
args.type = 'video/mp4'
}
return `
<div class="tag-plugin video">
<video controls preload>
<source src="${args.src}" type="${args.type}">Your browser does not support the video tag.
</video>
</div>
`
}

View File

@ -0,0 +1,9 @@
audio,video
border-radius: $border-block
max-width: 100%
video
z-index: 1
box-shadow: $boxshadow-card-float
.video
line-height: 0
text-align: center