Skip to content

Commit 64ff89e

Browse files
Be resilient to what structure youtube has in front matter
It can be full url or video id
1 parent 37b2264 commit 64ff89e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

_layouts/blog-post.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ <h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}
1313
</time>
1414
<span class="post-meta text-muted">&nbsp;</span>
1515
{%- if page.youtube -%}
16+
{% if page.youtube contains "http" %}
17+
{% assign youtube_url = page.youtube %}
18+
{% else %}
19+
{% assign youtube_url = "https://www.youtube.com/watch?v=" | append: page.youtube %}
20+
{% endif %}
1621
<span>
17-
<a href="{{ page.youtube }}" class="d-inline-flex align-items-center">
22+
<a href="{{ youtube_url }}" class="d-inline-flex align-items-center">
1823
<em class="bi bi-youtube youtube-red fs-2 mr-2"></em>
1924
</a>
2025
</span>

_layouts/home.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ <h2 class="card-title">
2020
<span class="card-subtitle mb-2 text-muted">Posté le {{ post.date | date: site.date_format }}</span>
2121
<span class="card-subtitle mb-2 text-muted">&nbsp;</span>
2222
{%- if post.youtube -%}
23+
{% if post.youtube contains "http" %}
24+
{% assign youtube_url = post.youtube %}
25+
{% else %}
26+
{% assign youtube_url = "https://www.youtube.com/watch?v=" | append: post.youtube %}
27+
{% endif %}
2328
<span>
24-
<a href="{{ post.youtube }}" class="d-inline-flex align-items-center">
29+
<a href="{{ youtube_url }}" class="d-inline-flex align-items-center">
2530
<em class="bi bi-youtube youtube-red fs-2 mr-2"></em>
2631
</a>
2732
</span>

0 commit comments

Comments
 (0)