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

- old
+ new

@@ -17,10 +17,13 @@ @month_link_template = uri_template blog_options.month_link @year_link_template = uri_template blog_options.year_link @day_template = blog_options.day_template @month_template = blog_options.month_template @year_template = blog_options.year_template + @generate_year_pages = blog_options.generate_year_pages + @generate_month_pages = blog_options.generate_month_pages + @generate_day_pages = blog_options.generate_day_pages end # Get a path to the given calendar page, based on the :year_link, :month_link or :day_link setting. # @param [Number] year # @param [Number] month @@ -43,21 +46,21 @@ def manipulate_resource_list(resources) new_resources = [] # Set up date pages if the appropriate templates have been specified @blog_data.articles.group_by {|a| a.date.year }.each do |year, year_articles| - if @year_template + if @generate_year_pages && @year_template new_resources << year_page_resource(year, year_articles) end year_articles.group_by {|a| a.date.month }.each do |month, month_articles| - if @month_template + if @generate_month_pages && @month_template new_resources << month_page_resource(year, month, month_articles) end month_articles.group_by {|a| a.date.day }.each do |day, day_articles| - if @day_template + if @generate_day_pages && @day_template new_resources << day_page_resource(year, month, day, day_articles) end end end end @@ -66,13 +69,11 @@ end private def year_page_resource(year, year_articles) - Sitemap::Resource.new(@sitemap, link(year)).tap do |p| - p.proxy_to(@year_template) - + Sitemap::ProxyResource.new(@sitemap, link(year), @year_template).tap do |p| # Add metadata in local variables so it's accessible to # later extensions p.add_metadata locals: { 'page_type' => 'year', 'year' => year, @@ -81,13 +82,11 @@ } end end def month_page_resource(year, month, month_articles) - Sitemap::Resource.new(@sitemap, link(year, month)).tap do |p| - p.proxy_to(@month_template) - + Sitemap::ProxyResource.new(@sitemap, link(year, month), @month_template).tap do |p| p.add_metadata locals: { 'page_type' => 'month', 'year' => year, 'month' => month, 'articles' => month_articles, @@ -95,12 +94,10 @@ } end end def day_page_resource(year, month, day, day_articles) - Sitemap::Resource.new(@sitemap, link(year, month, day)).tap do |p| - p.proxy_to(@day_template) - + Sitemap::ProxyResource.new(@sitemap, link(year, month, day), @day_template).tap do |p| p.add_metadata locals: { 'page_type' => 'day', 'year' => year, 'month' => month, 'day' => day,