我的 Jekyll 站点中有几个元素不能很好地用于摘录,尤其是在 RSS 提要中使用时。由于它们是由 Liquid 标签创建的(在自定义插件中实现),我认为它应该很容易做到。这样的事情看起来很谨慎:
module Jekyll
class MyTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
end
def render(context)
if <in excerpt>
""
else
"this should not be in an excerpt"
end
end
end
end
Liquid::Template.register_tag('mytag', Jekyll::MyTag)
不过,我看不到如何检查标签是否为摘录呈现。context.environments
转储的contentxcontext.scopes
并context.registers
没有透露任何有用的信息。
我怎样才能做到这一点?