Class: Dimples::Post

Inherits:
Entry
  • Object
show all
Defined in:
lib/dimples/post.rb

Overview

A single post for a site.

Constant Summary

Constants inherited from Entry

Entry::DEFAULT_FILENAME, Entry::FRONT_MATTER_PATTERN

Class Attribute Summary collapse

Attributes inherited from Entry

#contents, #metadata, #path, #rendered_contents

Instance Method Summary collapse

Methods inherited from Entry

#method_missing, #parse_metadata, #respond_to_missing?

Constructor Details

#initialize(path:) ⇒ Post

Returns a new instance of Post.



12
13
14
# File 'lib/dimples/post.rb', line 12

def initialize(path:)
  super(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

.markdownObject (readonly)

Returns the value of attribute markdown.



9
10
11
# File 'lib/dimples/post.rb', line 9

def markdown
  @markdown
end

Instance Method Details

#render(context: nil) ⇒ Object



20
21
22
# File 'lib/dimples/post.rb', line 20

def render(context: nil)
  Dimples::Post.markdown.render(contents)
end

#slugObject



16
17
18
# File 'lib/dimples/post.rb', line 16

def slug
  File.basename(path, File.extname(path))&.downcase
end