Class: Contentful::MiddlemanPages::Extension
- Inherits:
-
Middleman::Extension
- Object
- Middleman::Extension
- Contentful::MiddlemanPages::Extension
- Includes:
- UriTemplate
- Defined in:
- lib/contentful/middleman-pages/extension.rb
Constant Summary collapse
- SOURCE_PATH =
'source'
Instance Method Summary collapse
-
#after_configuration ⇒ Object
Middleman hooks.
-
#initialize(app, options, &block) ⇒ Extension
constructor
A new instance of Extension.
- #manipulate_resource_list(resources) ⇒ Object
Methods included from UriTemplate
Constructor Details
#initialize(app, options, &block) ⇒ Extension
Returns a new instance of Extension.
61 62 63 64 65 |
# File 'lib/contentful/middleman-pages/extension.rb', line 61 def initialize(app, , &block) super @contentful_resources = [] end |
Instance Method Details
#after_configuration ⇒ Object
Middleman hooks
70 71 72 |
# File 'lib/contentful/middleman-pages/extension.rb', line 70 def after_configuration end |
#manipulate_resource_list(resources) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/contentful/middleman-pages/extension.rb', line 74 def manipulate_resource_list(resources) new_resources_list = resources @contentful_resources += .data.map do |entry_id, entry_data| = entry_data resource = ::Middleman::Sitemap::Resource.new( @app.sitemap, , .template ) resource.extend ResourceInstanceMethods resource.data = entry_data resource. locals: entry_data if (index = is_existing_resource?(resource, new_resources_list)) new_resources_list[index] = resource else new_resources_list << resource end resource end (resources + @contentful_resources).map do |resource| = resource..fetch(:locals).fetch(:contentful, {}.to_hashugar) [@space_name] = {@content_type_name => @contentful_resources}.to_hashugar resource. locals: {contentful: } resource end new_resources_list end |