Last active
February 8, 2019 13:11
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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