make sure pages with published being false are not generated

This commit is contained in:
liufengyun
2014-01-12 17:40:14 +08:00
parent e7139cbd85
commit 22e1e5f28c
7 changed files with 27 additions and 15 deletions

View File

@@ -21,6 +21,11 @@ module Jekyll
self.content || ''
end
# Whether the file is published or not, as indicated in YAML front-matter
def published?
!(self.data.has_key?('published') && self.data['published'] == false)
end
# Returns merged option hash for File.read of self.site (if exists)
# and a given param
def merged_file_read_opts(opts)

View File

@@ -35,7 +35,7 @@ module Jekyll
attr_accessor :site
attr_accessor :data, :extracted_excerpt, :content, :output, :ext
attr_accessor :date, :slug, :published, :tags, :categories
attr_accessor :date, :slug, :tags, :categories
attr_reader :name
@@ -60,20 +60,10 @@ module Jekyll
self.date = Time.parse(self.data["date"].to_s)
end
self.published = self.published?
self.populate_categories
self.populate_tags
end
def published?
if self.data.has_key?('published') && self.data['published'] == false
false
else
true
end
end
def populate_categories
if self.categories.empty?
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.to_s.downcase}

View File

@@ -170,7 +170,8 @@ module Jekyll
f_rel = File.join(dir, f)
read_directories(f_rel) unless self.dest.sub(/\/$/, '') == f_abs
elsif has_yaml_header?(f_abs)
pages << Page.new(self, self.source, dir, f)
page = Page.new(self, self.source, dir, f)
pages << page if page.published?
else
static_files << StaticFile.new(self, self.source, dir, f)
end
@@ -189,7 +190,7 @@ module Jekyll
posts = read_content(dir, '_posts', Post)
posts.each do |post|
if post.published && (self.future || post.date <= self.time)
if post.published? && (self.future || post.date <= self.time)
aggregate_post_info(post)
end
end