Module: Bridgetown::Publishable

Included in:
GeneratedPage, Resource::Base
Defined in:
lib/bridgetown-core/concerns/publishable.rb

Instance Method Summary collapse

Instance Method Details

#publishable?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
# File 'lib/bridgetown-core/concerns/publishable.rb', line 12

def publishable?
  return true if collection.data?
  return false unless published? || @site.config.unpublished

  future_allowed = collection..future || @site.config.future
  this_time = date.is_a?(Date) ? date.to_time.to_i : date.to_i

  future_allowed || this_time <= @site.time.to_i
end

#published?Boolean

Whether the resource is published or not, as indicated in YAML front-matter

Returns:

  • (Boolean)


8
9
10
# File 'lib/bridgetown-core/concerns/publishable.rb', line 8

def published?
  !(data.key?("published") && data["published"] == false)
end