Skip to content

Instantly share code, notes, and snippets.

@mike-casas
Created October 6, 2016 02:34
Show Gist options
  • Save mike-casas/ac520c40e9d6cb5ee722a15259373621 to your computer and use it in GitHub Desktop.
Save mike-casas/ac520c40e9d6cb5ee722a15259373621 to your computer and use it in GitHub Desktop.
plugins keywords_text ruby
f = open("./keywords.txt")
$smartlist = []
f.each_line { |line| $smartlist.push line.strip }
f.close
module Jekyll
module KeywordsText
def keywords_text(text)
@arr=[]
$smartlist.map { |word|
if text.scan(/#{word}/).flatten.any?
@arr.push(word)
end
}
@arr.join(',')
end
end
end
Liquid::Template.register_filter(Jekyll::KeywordsText)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment