module Jekyll::Contentful::RichTextFilter
Liquid filter for the RichText field.
Public Instance Methods
rich_text(field, space = nil)
click to toggle source
# File lib/jekyll-contentful-data-import/helpers.rb, line 7 def rich_text(field, space = nil) return if field.nil? RichTextRenderer::Renderer.new(mappings_for(space)).render(field) end
Private Instance Methods
config_for(space)
click to toggle source
# File lib/jekyll-contentful-data-import/helpers.rb, line 24 def config_for(space) config = @context.registers[:site].config['contentful']['spaces'] # Spaces is a list of hashes indexed by space alias return config.first.first[1] if space.nil? # Return the first available configuration config.find { |sc| sc.key?(space) }[space] end
mappings_for(space)
click to toggle source
# File lib/jekyll-contentful-data-import/helpers.rb, line 15 def mappings_for(space) mappings = {} config_for(space).fetch('rich_text_mappings', {}).each do |k, v| mappings[k.to_s] = Module.const_get(v) end mappings end