Skip to content

Commit 51fdde5

Browse files
committed
feat: add video shortcode
1 parent 7a7a2f4 commit 51fdde5

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

content/blog/say-hello-to-doks/index.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,39 @@ weight: 50
99
images: ["say-hello-to-doks.png"]
1010
contributors: ["Henk Verlinde"]
1111
---
12+
13+
## Video shortcode
14+
15+
### Usage
16+
17+
```md
18+
{{</* video ratio="16x9" attributes="controls autoplay muted" webm-src="videos/flower.webm" mp4-src="videos/flower.mp4" */>}}
19+
```
20+
21+
| Parameters | Values |
22+
|----------|-------------|------|
23+
| ratio | <1x1 \| 4x3 \| 16x9 \| 21x9> |
24+
| attributes | [[Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attributes)] |
25+
| webm-src | [path/to/file.webm] |
26+
| mp4-src | [path/to/file.mp4] |
27+
{.table-striped}
28+
29+
### Renders
30+
31+
```html
32+
<div class="ratio ratio-16x9">
33+
<video controls autoplay muted>
34+
<source src="/videos/flower.webm" type="video/webm">
35+
<source src="/videos/flower.mp4" type="video/mp4">
36+
Sorry, your browser doesn't support embedded videos.
37+
</video>
38+
</div>
39+
```
40+
41+
{{< video ratio="16x9" attributes="controls autoplay muted" webm-src="videos/flower.webm" mp4-src="/videos/flower.mp4" >}}
42+
43+
## Resources
44+
45+
- [\<video\>: The Video Embed element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video)
46+
- [Ratios](https://getbootstrap.com/docs/5.0/helpers/ratio/)
47+
- [Custom aspect ratios](https://getbootstrap.com/docs/5.0/helpers/ratio/#sass-map)

layouts/shortcodes/video.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="ratio ratio-{{ with .Get "ratio" }}{{.}}{{ end }}">
2+
<video{{ with .Get "attributes" }} {{ . | safeHTMLAttr }}{{ end }}>
3+
{{ with .Get "webm-src" -}}
4+
<source src="{{ . | relURL }}" type="video/webm">
5+
{{ end -}}
6+
{{ with .Get "mp4-src" -}}
7+
<source src="{{ . | relURL }}" type="video/mp4">
8+
{{ end -}}
9+
Sorry, your browser doesn't support embedded videos.
10+
</video>
11+
</div>

static/videos/flower.mp4

1.08 MB
Binary file not shown.

static/videos/flower.webm

541 KB
Binary file not shown.

0 commit comments

Comments
 (0)