mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-30 01:08:26 -05:00
add the Publisher class to handle publishing logic
This commit is contained in:
@@ -50,6 +50,7 @@ require 'jekyll/related_posts'
|
||||
require 'jekyll/cleaner'
|
||||
require 'jekyll/entry_filter'
|
||||
require 'jekyll/layout_reader'
|
||||
require 'jekyll/publisher'
|
||||
|
||||
# extensions
|
||||
require 'jekyll/plugin'
|
||||
|
||||
21
lib/jekyll/publisher.rb
Normal file
21
lib/jekyll/publisher.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
module Jekyll
|
||||
class Publisher
|
||||
def initialize(site)
|
||||
@site = site
|
||||
end
|
||||
|
||||
def publish?(thing)
|
||||
can_be_published?(thing) && !hidden_in_the_future?(thing)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def can_be_published?(thing)
|
||||
thing.data.fetch('published', true) || @site.unpublished
|
||||
end
|
||||
|
||||
def hidden_in_the_future?(thing)
|
||||
thing.is_a?(Post) && !@site.future && thing.date > @site.time
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user