Skip to content

Commit

Permalink
feat: add the skip_forward and skip_backward site parameters (#65)
Browse files Browse the repository at this point in the history
feat: add the `skipForward` and `skipBackward` parameters for shortcode
  • Loading branch information
razonyang authored Sep 24, 2024
1 parent 20f2cfe commit 9c71fd6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
css_url = "https://unpkg.com/video.js/dist/video-js.min.css"
js_url = "https://unpkg.com/video.js/dist/video.min.js"
playback_rates = [0.5, 1, 1.5, 2]
# skip_forward = 5 # 5, 10 or 30.
# skip_backward = 5 # 5, 10 or 30.
12 changes: 12 additions & 0 deletions layouts/partials/video-js/video.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<script src="https://cdn.jsdelivr.net/npm/videojs-mobile-ui/dist/videojs-mobile-ui.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/videojs-mobile-ui/dist/videojs-mobile-ui.css">
<div
class="video-js-container">
{{- $class := slice "video-js vjs-default-skin" }}
Expand All @@ -10,6 +12,16 @@
{{- with default site.Params.video_js.playback_rates .playbackRates }}
{{- $options.Set "playbackRates" . }}
{{- end }}
{{- $controlBar := newScratch }}
{{- with default site.Params.video_js.skip_forward .skipForward }}
{{- $controlBar.SetInMap "skipButtons" "forward" . }}
{{- end }}
{{- with default site.Params.video_js.skip_backward .skipBackward }}
{{- $controlBar.SetInMap "skipButtons" "backward" . }}
{{- end }}
{{- with $controlBar.Values }}
{{- $options.Set "controlBar" . }}
{{- end }}
<video
data-setup="{{ $options.Values | jsonify }}"
width="100%"
Expand Down
6 changes: 6 additions & 0 deletions layouts/shortcodes/video-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
{{- $autoplay := false }}
{{- $aspectRatio := "" }}
{{- $playbackRates := "" }}
{{- $skipForward := 0 }}
{{- $skipBackward := 0 }}
{{- if .IsNamedParams }}
{{- $src = .Get "src" }}
{{- with .Get "type" }}{{ $type = . }}{{ end }}
Expand All @@ -17,6 +19,8 @@
{{- if isset .Params "autoplay" }}{{ $autoplay = .Get "autoplay" }}{{ end }}
{{- with .Get "aspectRatio" }}{{ $aspectRatio = . }}{{ end }}
{{- with .Get "playbackRates" }}{{ $playbackRates = . }}{{ end }}
{{- with .Get "skipForward" }}{{ $skipForward = . }}{{ end }}
{{- with .Get "skipBackward" }}{{ $skipBackward = . }}{{ end }}
{{- else }}
{{- $src = .Get 0 }}
{{- end }}
Expand All @@ -33,4 +37,6 @@
"preload" $preload
"aspectRatio" $aspectRatio
"playbackRates" $playbackRates
"skipForward" $skipForward
"skipBackward" $skipBackward
) }}

0 comments on commit 9c71fd6

Please sign in to comment.