11module Jekyll
22 module Archives
3- class Archive
4- include Convertible
3+ class Archive < Jekyll ::Page
54
6- attr_accessor :posts , :type , :name , :slug
7- attr_accessor :data , :content , :output
8- attr_accessor :path , :ext
9- attr_accessor :site
5+ attr_accessor :posts , :type , :slug
106
117 # Attributes for Liquid templates
12- ATTRIBUTES_FOR_LIQUID = %w[
8+ ATTRIBUTES_FOR_LIQUID = %w(
139 posts
1410 type
1511 title
1612 date
1713 name
1814 path
1915 url
20- ]
16+ ) . freeze
2117
2218 # Initialize a new Archive page
2319 #
@@ -90,31 +86,6 @@ def url
9086 raise ArgumentError . new "Template \" #{ template } \" provided is invalid."
9187 end
9288
93- # Add any necessary layouts to this post
94- #
95- # layouts - The Hash of {"name" => "layout"}.
96- # site_payload - The site payload Hash.
97- #
98- # Returns nothing.
99- def render ( layouts , site_payload )
100- payload = Utils . deep_merge_hashes ( {
101- "page" => to_liquid
102- } , site_payload )
103-
104- do_layout ( payload , layouts )
105- end
106-
107- # Convert this Convertible's data to a Hash suitable for use by Liquid.
108- #
109- # Returns the Hash representation of this Convertible.
110- def to_liquid ( attrs = nil )
111- further_data = Hash [ ( attrs || self . class ::ATTRIBUTES_FOR_LIQUID ) . map { |attribute |
112- [ attribute , send ( attribute ) ]
113- } ]
114-
115- Utils . deep_merge_hashes ( data , further_data )
116- end
117-
11889 # Produce a title object suitable for Liquid based on type of archive.
11990 #
12091 # Returns a String (for tag and category archives) and nil for
@@ -135,17 +106,6 @@ def date
135106 end
136107 end
137108
138- # Obtain destination path.
139- #
140- # dest - The String path to the destination dir.
141- #
142- # Returns the destination file path String.
143- def destination ( dest )
144- path = Jekyll . sanitized_path ( dest , URL . unescape_path ( url ) )
145- path = File . join ( path , "index.html" ) if url =~ /\/ $/
146- path
147- end
148-
149109 # Obtain the write path relative to the destination directory
150110 #
151111 # Returns the destination relative path String.
@@ -159,11 +119,6 @@ def relative_path
159119 def inspect
160120 "#<Jekyll:Archive @type=#{ @type . to_s } @title=#{ @title } @data=#{ @data . inspect } >"
161121 end
162-
163- # Returns the Boolean of whether this Page is HTML or not.
164- def html?
165- true
166- end
167122 end
168123 end
169124end
0 commit comments