lib/middleman-blog/paginator.rb in middleman-blog-3.6.0.beta.2 vs lib/middleman-blog/paginator.rb in middleman-blog-4.0.0

- old
+ new

@@ -23,23 +23,23 @@ next if res.ignored? # Avoid recomputing metadata over and over md = res.metadata - next unless md[:page]["pageable"] + next unless md[:page][:pageable] # Skip other blogs' resources next unless match_blog(res, md) # "articles" local variable is populated by Calendar and Tag page generators # If it's not set then use the complete list of articles # TODO: Some way to allow the frontmatter to specify the article filter? articles = md[:locals]["articles"] || @blog_controller.data.articles # Allow blog.per_page and blog.page_link to be overridden in the frontmatter - per_page = md[:page]["per_page"] || @per_page - page_link = uri_template(md[:page]["page_link"] || @page_link) + per_page = md[:page][:per_page] || @per_page + page_link = uri_template(md[:page][:page_link] || @page_link) num_pages = (articles.length / per_page.to_f).ceil # Add the pagination metadata to the base page (page 1) res.add_metadata locals: page_locals(1, num_pages, per_page, nil, articles) @@ -71,11 +71,11 @@ # Does this resource match the blog controller for this paginator? # @return [Boolean] def match_blog(res, md) res_controller = md[:locals]["blog_controller"] || (res.respond_to?(:blog_controller) && res.blog_controller) return false if res_controller && res_controller != @blog_controller - override_controller = md[:page]["blog"] + override_controller = md[:page][:blog] return false if override_controller && override_controller.to_s != @blog_controller.name.to_s true end @@ -83,12 +83,14 @@ # @param [Sitemap::Resource] res the original resource # @param [Integer] page_num the page number to generate a resource for # @param [String] page_link The pagination link path component template def page_resource(res, page_num, page_link) path = page_sub(res, page_num, page_link) - Sitemap::Resource.new(@app.sitemap, path, res.source_file).tap do |p| - # Copy the proxy state from the base page. - p.proxy_to(res.proxied_to) if res.proxy? + + if res.is_a? Sitemap::ProxyResource + Sitemap::ProxyResource.new(@app.sitemap, path, res.target) + else + Sitemap::Resource.new(@app.sitemap, path, res.source_file) end end # @param [Integer] page_num the page number to generate a resource for # @param [Integer] num_pages Total number of pages