mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
31 lines
660 B
Ruby
31 lines
660 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jekyll
|
|
class Publisher
|
|
def initialize(site)
|
|
@site = site
|
|
end
|
|
|
|
def publish?(thing)
|
|
can_be_published?(thing) && !hidden_in_the_future?(thing)
|
|
end
|
|
|
|
def hidden_in_the_future?(thing)
|
|
thing.respond_to?(:date) &&
|
|
!@site.future &&
|
|
!collection_allows_future?(thing) &&
|
|
thing.date.to_i > @site.time.to_i
|
|
end
|
|
|
|
private
|
|
|
|
def can_be_published?(thing)
|
|
thing.data.fetch("published", true) || @site.unpublished
|
|
end
|
|
|
|
def collection_allows_future?(thing)
|
|
thing.respond_to?(:collection) && !!thing.collection.metadata["future"]
|
|
end
|
|
end
|
|
end
|