Skip to content

Instantly share code, notes, and snippets.

@heardk
Last active February 8, 2019 13:11
Show Gist options
  • Save heardk/f43d408e0d836800dca7014d1450a3d8 to your computer and use it in GitHub Desktop.
Save heardk/f43d408e0d836800dca7014d1450a3d8 to your computer and use it in GitHub Desktop.
A custom Jekyll tag that looks for a TLDR blurb at the top of posts
module Jekyll
class TldrTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text
end
def render(context)
site = context.registers[:site]
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
<<-MARKUP.strip
<div class="tldr">
<div class="tldrTitle">tldr</div>
#{converter.convert(@text)}
</div>
MARKUP
end
end
end
Liquid::Template.register_tag('tldr', Jekyll::TldrTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment