Support embed YouTube playlist (#1342)

This commit is contained in:
Chiu-Hsiang Hsu 2021-02-07 16:13:03 +00:00 committed by GitHub
parent a65a2d52c7
commit 3cb61c3bcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -1,3 +1,3 @@
<div {% if class %}class="{{class}}"{% endif %}> <div {% if class %}class="{{class}}"{% endif %}>
<iframe src="https://www.youtube-nocookie.com/embed/{{id}}{% if autoplay %}?autoplay=1{% endif %}" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <iframe src="https://www.youtube-nocookie.com/embed/{{id}}{% if playlist %}?list={{playlist}}{% endif %}{% if autoplay %}?autoplay=1{% endif %}" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div> </div>

View file

@ -164,6 +164,7 @@ Embed a responsive player for a YouTube video.
The arguments are: The arguments are:
- `id`: the video id (mandatory) - `id`: the video id (mandatory)
- `playlist: the playlist id (optional)
- `class`: a class to add to the `<div>` surrounding the iframe - `class`: a class to add to the `<div>` surrounding the iframe
- `autoplay`: when set to "true", the video autoplays on load - `autoplay`: when set to "true", the video autoplays on load
@ -172,6 +173,8 @@ Usage example:
```md ```md
{{/* youtube(id="dQw4w9WgXcQ") */}} {{/* youtube(id="dQw4w9WgXcQ") */}}
{{/* youtube(id="dQw4w9WgXcQ", playlist="RDdQw4w9WgXcQ") */}}
{{/* youtube(id="dQw4w9WgXcQ", autoplay=true) */}} {{/* youtube(id="dQw4w9WgXcQ", autoplay=true) */}}
{{/* youtube(id="dQw4w9WgXcQ", autoplay=true, class="youtube") */}} {{/* youtube(id="dQw4w9WgXcQ", autoplay=true, class="youtube") */}}