11module Jekyll
22 module Archives
33 class Archive < Jekyll ::Page
4-
54 attr_accessor :posts , :type , :slug
65
76 # Attributes for Liquid templates
@@ -30,10 +29,9 @@ def initialize(site, title, type, posts)
3029 @title = title
3130 @config = site . config [ "jekyll-archives" ]
3231
33- # Generate slug if tag or category (taken from jekyll/jekyll/features/support/env.rb)
34- if title . is_a? String
35- @slug = Utils . slugify ( title )
36- end
32+ # Generate slug if tag or category
33+ # (taken from jekyll/jekyll/features/support/env.rb)
34+ @slug = Utils . slugify ( title ) if title . is_a? String
3735
3836 # Use ".html" for file extension and url for path
3937 @ext = File . extname ( relative_path )
@@ -68,7 +66,7 @@ def layout
6866 # desired placeholder replacements. For details see "url.rb".
6967 def url_placeholders
7068 if @title . is_a? Hash
71- @title . merge ( { :type => @type } )
69+ @title . merge ( :type => @type )
7270 else
7371 { :name => @slug , :type => @type }
7472 end
@@ -88,7 +86,7 @@ def url
8886 end
8987
9088 def permalink
91- data && data . is_a? ( Hash ) && data [ ' permalink' ]
89+ data && data . is_a? ( Hash ) && data [ " permalink" ]
9290 end
9391
9492 # Add any necessary layouts to this post
@@ -115,7 +113,7 @@ def add_dependencies
115113 end
116114 end
117115 end
118-
116+
119117 # Convert this Convertible's data to a Hash suitable for use by Liquid.
120118 #
121119 # Returns the Hash representation of this Convertible.
@@ -132,9 +130,7 @@ def to_liquid(attrs = nil)
132130 # Returns a String (for tag and category archives) and nil for
133131 # date-based archives.
134132 def title
135- if @title . is_a? String
136- @title
137- end
133+ @title if @title . is_a? String
138134 end
139135
140136 # Produce a date object if a date-based archive
@@ -151,8 +147,8 @@ def date
151147 #
152148 # Returns the destination relative path String.
153149 def relative_path
154- path = URL . unescape_path ( url ) . gsub ( / ^\/ / , "" )
155- path = File . join ( path , "index.html" ) if url =~ / \/ $/
150+ path = URL . unescape_path ( url ) . gsub ( %r! ^\/ ! , "" )
151+ path = File . join ( path , "index.html" ) if url =~ %r! \/ $!
156152 path
157153 end
158154
0 commit comments