@@ -13,6 +13,7 @@ class Archive < Jekyll::Page
1313 name
1414 path
1515 url
16+ permalink
1617 ) . freeze
1718
1819 # Initialize a new Archive page
@@ -30,8 +31,8 @@ def initialize(site, title, type, posts)
3031 @config = site . config [ 'jekyll-archives' ]
3132
3233 # Generate slug if tag or category (taken from jekyll/jekyll/features/support/env.rb)
33- if title . to_s . length
34- @slug = Utils . slugify ( title . to_s )
34+ if title . is_a? String
35+ @slug = Utils . slugify ( title )
3536 end
3637
3738 # Use ".html" for file extension and url for path
@@ -86,6 +87,46 @@ def url
8687 raise ArgumentError . new "Template \" #{ template } \" provided is invalid."
8788 end
8889
90+ def permalink
91+ data && data . is_a? ( Hash ) && data [ 'permalink' ]
92+ end
93+
94+ # Add any necessary layouts to this post
95+ #
96+ # layouts - The Hash of {"name" => "layout"}.
97+ # site_payload - The site payload Hash.
98+ #
99+ # Returns nothing.
100+ def render ( layouts , site_payload )
101+ payload = Utils . deep_merge_hashes ( {
102+ "page" => to_liquid
103+ } , site_payload )
104+
105+ do_layout ( payload , layouts )
106+ end
107+
108+ # Add dependencies for incremental mode
109+ def add_dependencies
110+ if defined? site . regenerator
111+ archive_path = site . in_dest_dir ( relative_path )
112+ site . regenerator . add ( archive_path )
113+ @posts . each do |post |
114+ site . regenerator . add_dependency ( archive_path , post . path )
115+ end
116+ end
117+ end
118+
119+ # Convert this Convertible's data to a Hash suitable for use by Liquid.
120+ #
121+ # Returns the Hash representation of this Convertible.
122+ def to_liquid ( attrs = nil )
123+ further_data = Hash [ ( attrs || self . class ::ATTRIBUTES_FOR_LIQUID ) . map { |attribute |
124+ [ attribute , send ( attribute ) ]
125+ } ]
126+
127+ Utils . deep_merge_hashes ( data , further_data )
128+ end
129+
89130 # Produce a title object suitable for Liquid based on type of archive.
90131 #
91132 # Returns a String (for tag and category archives) and nil for
@@ -115,6 +156,14 @@ def relative_path
115156 path
116157 end
117158
159+ def regenerate?
160+ if defined? site . regenerator
161+ site . regenerator . regenerate? ( self )
162+ else
163+ true
164+ end
165+ end
166+
118167 # Returns the object as a debug String.
119168 def inspect
120169 "#<Jekyll:Archive @type=#{ @type . to_s } @title=#{ @title } @data=#{ @data . inspect } >"
0 commit comments