Sha256: f306ef92d2cb3f2cc799b31d697cd9c3069e6e3c2b8cea12d72ba740a8076ace
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module Jekyll module Maps class LocationFinder def initialize(options) @documents = [] @options = options end def find(site, page) if @options[:flags][:on_page] @documents << page if location?(page) else site.collections.each { |_, collection| filter(collection.docs) } site.data.each { |_, docs| filter(docs) } end @documents.map do |document| { :latitude => document["location"]["latitude"], :longitude => document["location"]["longitude"], :title => document["title"], :url => document["url"] || document.url, :image => document["image"] || "" } end end private def filter(docs) docs.each do |doc| @documents << doc if location?(doc) && match_filters?(doc) end end private def location?(doc) !doc["location"].nil? && !doc["location"].empty? end private def match_filters?(doc) @options[:filters].each do |key, value| return false if doc[key].nil? || doc[key] != value end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-maps-1.1.4 | lib/jekyll-maps/location_finder.rb |