11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/jekyll-open-sdg-plugins/validate_site_config.rb', line 11
def generate(site)
schema_path = File.join(File.dirname(__FILE__), 'schema-site-config.json')
json_from_file = File.read(schema_path)
schema = JSON.parse(json_from_file)
schemer = JSONSchemer.schema(schema)
if site.config.has_key?('validate_site_config') && site.config['validate_site_config']
unless schemer.valid?(site.config)
opensdg_notice('Site configuration invalid:')
errors = schemer.validate(site.config).to_a
errors.each { |error| opensdg_validation_error(error) }
opensdg_notice "The site configuration is not valid. See feedback above."
raise "Invalid site configuration"
end
end
site.data['schema-site-config'] = schema
end
|