Skip to content

Commit cda62e2

Browse files
authored
feat: add support for embed spotify (#2515)
1 parent 5f8ec7f commit cda62e2

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

_includes/embed/audio.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{% endunless %}
1010

1111
<p>
12-
<audio class="embed-audio" controls>
12+
<audio class="embed-audio file" controls>
1313
{% assign extension = src | split: '.' | last %}
1414
{% assign types = extension | concat: types %}
1515

_includes/embed/spotify.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% assign size = 352 %}
2+
{% assign theme = '' %}
3+
4+
{% if include.compact %}
5+
{% assign size = 152 %}
6+
{% endif %}
7+
8+
{% if include.dark %}
9+
{% assign theme = '?theme=0' %}
10+
{% endif %}
11+
12+
<iframe
13+
class="embed-audio spotify"
14+
src="https://open.spotify.com/embed/track/{{ include.id | append: theme }}"
15+
height="{{ size }}"
16+
frameBorder="0"
17+
allowfullscreen=""
18+
allowtransparency="true"
19+
allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
20+
loading="lazy"
21+
>
22+
</iframe>

_posts/2019-08-08-write-a-new-post.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,31 @@ For normal images:
256256
```
257257
{: .nolineno }
258258

259-
### Video
259+
### Social Media Platforms
260260

261-
#### Social Media Platform
262-
263-
You can embed videos from social media platforms with the following syntax:
261+
You can embed video/audio from social media platforms with the following syntax:
264262

265263
```liquid
266264
{% include embed/{Platform}.html id='{ID}' %}
267265
```
268266

269267
Where `Platform` is the lowercase of the platform name, and `ID` is the video ID.
270268

271-
The following table shows how to get the two parameters we need in a given video URL, and you can also know the currently supported video platforms.
269+
The following table shows how to get the two parameters we need in a given video/audio URL, and you can also know the currently supported video platforms.
270+
271+
| Video URL | Platform | ID |
272+
| -------------------------------------------------------------------------------------------------------------------------- | ---------- | :----------------------- |
273+
| [https://www.**youtube**.com/watch?v=**H-B46URT4mg**](https://www.youtube.com/watch?v=H-B46URT4mg) | `youtube` | `H-B46URT4mg` |
274+
| [https://www.**twitch**.tv/videos/**1634779211**](https://www.twitch.tv/videos/1634779211) | `twitch` | `1634779211` |
275+
| [https://www.**bilibili**.com/video/**BV1Q44y1B7Wf**](https://www.bilibili.com/video/BV1Q44y1B7Wf) | `bilibili` | `BV1Q44y1B7Wf` |
276+
| [https://www.open.**spotify**.com/track/**3OuMIIFP5TxM8tLXMWYPGV**](https://open.spotify.com/track/3OuMIIFP5TxM8tLXMWYPGV) | `spotify` | `3OuMIIFP5TxM8tLXMWYPGV` |
277+
278+
Spotify supports some additional parameters:
272279

273-
| Video URL | Platform | ID |
274-
| -------------------------------------------------------------------------------------------------- | ---------- | :------------- |
275-
| [https://www.**youtube**.com/watch?v=**H-B46URT4mg**](https://www.youtube.com/watch?v=H-B46URT4mg) | `youtube` | `H-B46URT4mg` |
276-
| [https://www.**twitch**.tv/videos/**1634779211**](https://www.twitch.tv/videos/1634779211) | `twitch` | `1634779211` |
277-
| [https://www.**bilibili**.com/video/**BV1Q44y1B7Wf**](https://www.bilibili.com/video/BV1Q44y1B7Wf) | `bilibili` | `BV1Q44y1B7Wf` |
280+
- `compact` - to display compact player instead (ex. `{% include embed/spotify.html id='3OuMIIFP5TxM8tLXMWYPGV' compact=1 %}`);
281+
- `dark` - to force dark theme (ex. `{% include embed/spotify.html id='3OuMIIFP5TxM8tLXMWYPGV' dark=1 %}`).
278282

279-
#### Video Files
283+
### Video Files
280284

281285
If you want to embed a video file directly, use the following syntax:
282286

@@ -310,7 +314,7 @@ Consider an example using all of the above:
310314
%}
311315
```
312316

313-
### Audios
317+
### Audio Files
314318

315319
If you want to embed an audio file directly, use the following syntax:
316320

_sass/base/_base.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,14 @@ main {
314314

315315
.embed-audio {
316316
width: 100%;
317-
display: block;
317+
318+
&.file {
319+
display: block;
320+
}
321+
322+
&.spotify {
323+
border-radius: 14px;
324+
}
318325

319326
@extend %img-caption;
320327
}

0 commit comments

Comments
 (0)