Skip to content

Commit 3006fd9

Browse files
authored
Merge pull request #67 from jekyll/page
Merge pull request 67
2 parents d194b42 + 7c1fe94 commit 3006fd9

File tree

2 files changed

+5
-70
lines changed

2 files changed

+5
-70
lines changed

lib/jekyll-archives.rb

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,8 @@ def generate(site)
4545
@site.config['jekyll-archives'] = @config
4646

4747
read
48-
render
49-
write
48+
@site.pages.concat(@archives)
5049

51-
@site.keep_files ||= []
52-
@archives.each do |archive|
53-
@site.keep_files << archive.relative_path
54-
end
5550
@site.config["archives"] = @archives
5651
end
5752

@@ -97,21 +92,6 @@ def enabled?(archive)
9792
end
9893
end
9994

100-
# Renders the archives into the layouts
101-
def render
102-
payload = @site.site_payload
103-
@archives.each do |archive|
104-
archive.render(@site.layouts, payload)
105-
end
106-
end
107-
108-
# Write archives to their destination
109-
def write
110-
@archives.each do |archive|
111-
archive.write(@site.dest)
112-
end
113-
end
114-
11595
def tags
11696
@site.post_attr_hash('tags')
11797
end

lib/jekyll-archives/archive.rb

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
module 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
169124
end

0 commit comments

Comments
 (0)