Merge pull request #196 from Mitrichius/add-video-shortcode

Add video shortcode
This commit is contained in:
Dmitry Kolosov 2023-08-03 18:41:05 +02:00 committed by GitHub
commit 86078074c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 2 deletions

View File

@ -275,6 +275,10 @@ If you use webmention.io you can also enable pingback with `pingback: true`
### Disabling comments per-page basis ### Disabling comments per-page basis
Add `disableComments: true` to post front matter. Add `disableComments: true` to post front matter.
## Custom shortcodes
### Video (for local videofiles)
Example: `{{< video src="/media/movie.mp4" type="video/mp4" preload="auto" caption="Some caption" alt="Some alt" >}}`
## Contributing ## Contributing
If you find a bug or have an idea for a feature, feel free to write an [issue](https://github.com/mitrichius/hugo-theme-anubis/issues) or make a PR. If you find a bug or have an idea for a feature, feel free to write an [issue](https://github.com/mitrichius/hugo-theme-anubis/issues) or make a PR.

View File

@ -537,6 +537,13 @@ article figcaption {
margin-bottom: 2em; margin-bottom: 2em;
} }
article video {
max-width: 100%;
display: block;
height: auto;
margin: 0 auto .5em;
}
code.has-jax { code.has-jax {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
background: inherit !important; background: inherit !important;

View File

@ -60,3 +60,6 @@ toNewPost:
toOldPost: toOldPost:
other: "to old post" other: "to old post"
videoIsNotSupported:
other: "Your browser does not support video"

View File

@ -57,3 +57,6 @@ toNewPost:
toOldPost: toOldPost:
other: "к старой записи" other: "к старой записи"
videoIsNotSupported:
other: "Ваш браузер не поддерживает видео"

View File

@ -0,0 +1,20 @@
<video
class="video-shortcode"
preload="{{ .Get "preload" | default "auto" }}"
controls
>
<source
src="{{ .Get "src" }}"
type="{{ .Get "type" }}"
{{ if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify | plainify }}{{ end }}"
{{ end }}
>
{{ i18n "videoIsNotSupported" }}
</video>
{{ if .Get "caption" }}
<figcaption>
{{ .Get "caption" | markdownify }}
</figcaption>
{{ end }}