Youtube Player di jekyll
Plugins untuk menampilkan Youtube
Pengantar
Youtube sudah gak perlu dijelaskan, sudah sangat terkenal. Nah, sekarang mari kita tampilkan youtube playernya di sini.
Plugins
Ini plugins dari pibby.
Cara Pakai
{% youtube VIDEO_ID %}
Contoh menampilkan video :
{% youtube EW92gv2GXvQ %}
Hasil
Cara Pasang
Copy-kan isi file youtube.rb
dalam folder _plugins
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Jekyll - Easy Youtube Embed
#
# Katie Harron - https://github.com/pibby
#
# Input:
# <div class="video"><figure><iframe width="640" height="480" src="//www.youtube.com/embed/Al9FOtZcadQ" frameborder="0" allowfullscreen></iframe></figure></div>
# Output:
# <div class="video">
# <figure>
# <iframe width="640" height="480" src="//www.youtube.com/embed/Al9FOtZcadQ" allowfullscreen></iframe>
# </figure>
# </div>
module Jekyll
class Youtube < Liquid::Tag
@url = nil
VIDEO_URL = /(\S+)/i
def initialize(tag_name, markup, tokens)
super
if markup =~ VIDEO_URL
@url = $1
end
end
def render(context)
source = "<div class=\"video\">"
source += "<figure>"
source += "<iframe width=\"640\" height=\"480\" src=\"//www.youtube.com/embed/#{@url}\" frameborder=\"0\" allowfullscreen></iframe>"
source += "</figure>"
source += "</div>"
source
end
end
end
Liquid::Template.register_tag('youtube', Jekyll::Youtube)