Class: Statique::Document
- Inherits:
-
Object
- Object
- Statique::Document
- Defined in:
- lib/statique/document.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #body ⇒ Object
- #engine_name ⇒ Object
-
#initialize(file, statique) ⇒ Document
constructor
A new instance of Document.
- #layout_name ⇒ Object
- #pagination_pages ⇒ Object
- #path ⇒ Object
- #published_at ⇒ Object
- #title ⇒ Object
- #view_name ⇒ Object
Constructor Details
#initialize(file, statique) ⇒ Document
Returns a new instance of Document.
9 10 11 12 |
# File 'lib/statique/document.rb', line 9 def initialize(file, statique) parsed = FrontMatterParser::Parser.parse_file(file) @file, , @content, @statique = file.freeze, Hashie::Mash.new(parsed.front_matter).freeze, parsed.content.freeze, statique end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/statique/document.rb', line 7 def content @content end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/statique/document.rb', line 7 def file @file end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
7 8 9 |
# File 'lib/statique/document.rb', line 7 def end |
Instance Method Details
#body ⇒ Object
39 40 41 |
# File 'lib/statique/document.rb', line 39 def body content end |
#engine_name ⇒ Object
27 28 29 |
# File 'lib/statique/document.rb', line 27 def engine_name extname.delete_prefix(".").freeze end |
#layout_name ⇒ Object
31 32 33 |
# File 'lib/statique/document.rb', line 31 def layout_name .fetch("layout") { "layout" }.freeze end |
#pagination_pages ⇒ Object
43 44 45 46 47 |
# File 'lib/statique/document.rb', line 43 def pagination_pages return unless @statique.discover.collections.key?(.paginates) collection = @statique.discover.collections[.paginates] (collection.size.to_f / Paginator.per_page).ceil end |
#path ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/statique/document.rb', line 14 def path case basename when "index.slim" then "/" when "index.md" then "/" else "/#{meta.permalink || basename.delete_suffix(extname).delete_prefix(@statique.configuration.paths.content.to_s)}" end.freeze end |
#published_at ⇒ Object
49 50 51 |
# File 'lib/statique/document.rb', line 49 def published_at @published_at ||= file.ctime.freeze end |
#title ⇒ Object
35 36 37 |
# File 'lib/statique/document.rb', line 35 def title .title.freeze end |
#view_name ⇒ Object
23 24 25 |
# File 'lib/statique/document.rb', line 23 def view_name basename.delete_suffix(extname).freeze end |