blob: f858007fc432c0af4ccfd1d09a26415949d1638e (
plain) (
tree)
|
|
# 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)
|