Sha256: 4a0a4a8325bed5f8b2fe4df339859a76f4471549a08db6ba26822fa491046b50
Contents?: true
Size: 930 Bytes
Versions: 118
Compression:
Stored size: 930 Bytes
Contents
require 'json' require 'hash-joiner' require 'open-uri' module Jekyll_Get class Generator < Jekyll::Generator safe true priority :highest def generate(site) config = site.config['jekyll_get'] if !config return end if !config.kind_of?(Array) config = [config] end config.each do |d| begin target = site.data[d['data']] source = JSON.load(open(d['json'])) if target HashJoiner.deep_merge target, source else site.data[d['data']] = source end if d['cache'] data_source = (site.config['data_source'] || '_data') path = "#{data_source}/#{d['data']}.json" open(path, 'wb') do |file| file << JSON.generate(site.data[d['data']]) end end rescue next end end end end end
Version data entries
118 entries across 118 versions & 1 rubygems