Class: Dimples::Post
Overview
A single post for a site.
Constant Summary
Constants inherited from Entry
Entry::DEFAULT_FILENAME, Entry::FRONT_MATTER_PATTERN
Class Attribute Summary collapse
-
.markdown ⇒ Object
readonly
Returns the value of attribute markdown.
Instance Attribute Summary collapse
-
#rendered_contents ⇒ Object
readonly
Returns the value of attribute rendered_contents.
Attributes inherited from Entry
#contents, #metadata, #path, #site
Instance Method Summary collapse
-
#initialize(site:, path:) ⇒ Post
constructor
A new instance of Post.
- #render(payload: nil) ⇒ Object
- #slug ⇒ Object
Methods inherited from Entry
#generate, #method_missing, #parse_metadata, #respond_to_missing?, #template
Constructor Details
#initialize(site:, path:) ⇒ Post
Returns a new instance of Post.
14 15 16 |
# File 'lib/dimples/post.rb', line 14 def initialize(site:, path:) super(site:, source: Pathname.new(path)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dimples::Entry
Class Attribute Details
.markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
9 10 11 |
# File 'lib/dimples/post.rb', line 9 def markdown @markdown end |
Instance Attribute Details
#rendered_contents ⇒ Object (readonly)
Returns the value of attribute rendered_contents.
12 13 14 |
# File 'lib/dimples/post.rb', line 12 def rendered_contents @rendered_contents end |
Instance Method Details
#render(payload: nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/dimples/post.rb', line 22 def render(payload: nil) @rendered_contents ||= Redcarpet::Render::SmartyPants.render( Dimples::Post.markdown.render(contents) ).strip end |
#slug ⇒ Object
18 19 20 |
# File 'lib/dimples/post.rb', line 18 def slug File.basename(path, File.extname(path))&.downcase end |