bune.city/_plugins/plugin.rb

23 lines
481 B
Ruby
Raw Normal View History

2020-04-05 06:34:03 +00:00
require "liquid"
require "jekyll"
require "nokogiri"
module Jekyll
module LynnesbianDotSpaceFilters
def summarise(excerpt)
doc = Nokogiri::HTML.fragment(excerpt) do |config|
config.noblanks
end
first_paragraph = doc.xpath(".//p")[0]
if first_paragraph.is_a?(NilClass) then
return "Couldn't generate a summary for this post."
else
return first_paragraph.text
end
end
end
end
Liquid::Template.register_filter(Jekyll::LynnesbianDotSpaceFilters)