Merge pull request #1639 from maul-esel/tags-and-categories
This commit is contained in:
commit
bc7aed290a
|
@ -1,8 +1,8 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
class Site
|
class Site
|
||||||
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
||||||
:categories, :exclude, :include, :source, :dest, :lsi, :highlighter,
|
:exclude, :include, :source, :dest, :lsi, :highlighter,
|
||||||
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
|
:permalink_style, :time, :future, :safe, :plugins, :limit_posts,
|
||||||
:show_drafts, :keep_files, :baseurl, :data, :file_read_opts, :gems
|
:show_drafts, :keep_files, :baseurl, :data, :file_read_opts, :gems
|
||||||
|
|
||||||
attr_accessor :converters, :generators
|
attr_accessor :converters, :generators
|
||||||
|
@ -50,8 +50,6 @@ module Jekyll
|
||||||
self.posts = []
|
self.posts = []
|
||||||
self.pages = []
|
self.pages = []
|
||||||
self.static_files = []
|
self.static_files = []
|
||||||
self.categories = Hash.new { |hash, key| hash[key] = [] }
|
|
||||||
self.tags = Hash.new { |hash, key| hash[key] = [] }
|
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
||||||
if limit_posts < 0
|
if limit_posts < 0
|
||||||
|
@ -238,9 +236,6 @@ module Jekyll
|
||||||
[posts, pages].flatten.each do |page_or_post|
|
[posts, pages].flatten.each do |page_or_post|
|
||||||
page_or_post.render(layouts, payload)
|
page_or_post.render(layouts, payload)
|
||||||
end
|
end
|
||||||
|
|
||||||
categories.values.map { |ps| ps.sort! { |a, b| b <=> a } }
|
|
||||||
tags.values.map { |ps| ps.sort! { |a, b| b <=> a } }
|
|
||||||
rescue Errno::ENOENT => e
|
rescue Errno::ENOENT => e
|
||||||
# ignore missing layout dir
|
# ignore missing layout dir
|
||||||
end
|
end
|
||||||
|
@ -277,10 +272,18 @@ module Jekyll
|
||||||
# array of posts ) then sort each array in reverse order.
|
# array of posts ) then sort each array in reverse order.
|
||||||
hash = Hash.new { |h, key| h[key] = [] }
|
hash = Hash.new { |h, key| h[key] = [] }
|
||||||
posts.each { |p| p.send(post_attr.to_sym).each { |t| hash[t] << p } }
|
posts.each { |p| p.send(post_attr.to_sym).each { |t| hash[t] << p } }
|
||||||
hash.values.map { |sortme| sortme.sort! { |a, b| b <=> a } }
|
hash.values.each { |posts| posts.sort!.reverse! }
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tags
|
||||||
|
post_attr_hash('tags')
|
||||||
|
end
|
||||||
|
|
||||||
|
def categories
|
||||||
|
post_attr_hash('categories')
|
||||||
|
end
|
||||||
|
|
||||||
# Prepare site data for site payload. The method maintains backward compatibility
|
# Prepare site data for site payload. The method maintains backward compatibility
|
||||||
# if the key 'data' is already used in _config.yml.
|
# if the key 'data' is already used in _config.yml.
|
||||||
#
|
#
|
||||||
|
@ -376,8 +379,6 @@ module Jekyll
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def aggregate_post_info(post)
|
def aggregate_post_info(post)
|
||||||
posts << post
|
posts << post
|
||||||
post.categories.each { |c| categories[c] << post }
|
|
||||||
post.tags.each { |c| tags[c] << post }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def relative_permalinks_deprecation_method
|
def relative_permalinks_deprecation_method
|
||||||
|
|
Loading…
Reference in New Issue