我一直在寻找这也,这是一个PITA发现如何做到这一点,没有太多的谷歌内容,最准确的发现是一个要点,不会在这里工作......死了简单的解决方案:
./_plugins/markdown_tag.rb
:
module Jekyll
class MarkdownTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text.strip
end
require "kramdown"
def render(context)
tmpl = File.read File.join Dir.pwd, "_includes", @text
Jekyll::Converters::Markdown::KramdownParser.new(Jekyll.configuration()).convert(tmpl)
end
end
end
Liquid::Template.register_tag('markdown', Jekyll::MarkdownTag)
UPDATE:博客与用法示例:https://web.archive.org/web/20161207125751/http://wolfslittlestore.be/2013/10/rendering-markdown-in-jekyll/
此链接已经死了。这是回答问题而不是链接到解决方案更好的原因之一。 – askewchan
我喜欢最初的解决方案,但不是将捕获之间的包含,而是将我的内容,并将捕获+渲染移入我的_includes/sidebar.html – stackdump