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
|
# Plugin to help with releases
require 'uri'
module Jekyll
class ReleaseTag < Liquid::Tag
def initialize(tag, text, context)
super
@year, vol, thumbnail = text.split('|').map(&:strip)
@title = "Norsk Urskog Metal Sampler, Vol #{vol} #{@year}"
@thumbnail = Assets::Liquid::Tag.new('img', "#{thumbnail} magick:resize:400x alt:\"#{@title} cover\"", context)
end
def render(context)
# context.environments[0][:page]
#
# {“lang”=>”no”, “layout”=>”default”, “title”=>”Utgivelser”, “page-lang”=>false,
# “content”=>”...”, “dir”=>”/utgivelser/”, “name”=>”utgivelser.md”, “path”=>”utgivelser.md”,
# “url”=>”/utgivelser/”}
#
page = context.environments[0][:page]
%Q{<div class="release-thumbnail">
<a href="#{page['url']}#{@year}">#{@thumbnail.render(context)}<div class="release-thumbnail-title">#{@title}</div></a>
</div>}
end
end
end
Liquid::Template.register_tag('release', Jekyll::ReleaseTag)
|