Skip to content

Commit

Permalink
[feat] tag-plugin: audio & video
Browse files Browse the repository at this point in the history
  • Loading branch information
xaoxuu committed Jan 12, 2024
1 parent fc345c1 commit 2ed4d21
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions scripts/tags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 23 additions & 0 deletions scripts/tags/lib/audio.js
Original file line number Diff line number Diff line change
@@ -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>
`
}
2 changes: 1 addition & 1 deletion scripts/tags/lib/md.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
*
* {% md [src:url] %}
* {% md src %}
*
*/
'use strict'
Expand Down
23 changes: 23 additions & 0 deletions scripts/tags/lib/video.js
Original file line number Diff line number Diff line change
@@ -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>
`
}
9 changes: 9 additions & 0 deletions source/css/_common/media.styl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2ed4d21

Please sign in to comment.