class Bridgetown::Publisher

Public Class Methods

new(site) click to toggle source

@param site [Bridgetown::Site]

# File lib/bridgetown-core/publisher.rb, line 6
def initialize(site)
  @site = site
end

Public Instance Methods

hidden_in_the_future?(thing) click to toggle source
# File lib/bridgetown-core/publisher.rb, line 14
def hidden_in_the_future?(thing)
  return false unless thing.respond_to?(:date)

  future_allowed =
    thing.respond_to?(:collection) && thing.collection.metadata.future || @site.config.future
  thing_time = thing.date.is_a?(Date) ? thing.date.to_time.to_i : thing.date.to_i
  !future_allowed && thing_time > @site.time.to_i
end
publish?(thing) click to toggle source
# File lib/bridgetown-core/publisher.rb, line 10
def publish?(thing)
  can_be_published?(thing) && !hidden_in_the_future?(thing)
end

Private Instance Methods

can_be_published?(thing) click to toggle source
# File lib/bridgetown-core/publisher.rb, line 25
def can_be_published?(thing)
  thing.data.fetch("published", true) || @site.config.unpublished
end