module JekyllWikiLinks::TypeFilters

Public Instance Methods

doc_type(links, doc_type) click to toggle source

usage: {% assign note_links = page.links | doc_type = “notes” %} “doc_type” is the jekyll type (“pages”, “posts”, “<collection-name>”)

# File lib/jekyll-wikilinks/filter.rb, line 9
def doc_type(links, doc_type)
  return if links.nil?
  target_links = []
  links.each do |l|
    target_links << l if self.to_string(l['doc'].type) == doc_type.to_str
  end
  return target_links.uniq
end
to_string(type) click to toggle source
# File lib/jekyll-wikilinks/filter.rb, line 29
def to_string(type)
  return type if type.is_a?(String)
  type = type.to_s
  begin
    String(type)
  rescue ::ArgumentError
    raise ArgumentError, "invalid type"
  end
end