diff --git a/web/_plugins/cardLinkGenerator.rb b/web/_plugins/cardLinkGenerator.rb new file mode 100644 index 0000000..a6bfc1f --- /dev/null +++ b/web/_plugins/cardLinkGenerator.rb @@ -0,0 +1,24 @@ +module Jekyll + + class CardLinkGenerator < Generator + + def card_link(name, text = '') + if text.nil? || !defined?(text) || (text == '') then + text = name.split("-").map(&:capitalize).join(" ") + end + "#{text}" + end + + def generate(site) + site.pages.each do |page| + related = Set.new page.data['related'] + page.content.scan(/\[%([^]]*)\](?:\(([^)]*)\))?/).each do |match| + related.add(match[0]) + page.content = page.content.sub(/\[%([^]]*)\](?:\(([^)]*)\))?/, card_link(match[0], match[1])) + end + page.data['related'] = related.to_a + end + end + end + +end