Class: Dimples::Entries::Post

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

Overview

A page from a site with a date.

Constant Summary

Constants inherited from Base

Base::FRONT_MATTER_PATTERN

Instance Attribute Summary

Attributes inherited from Base

#contents, #metadata, #path, #rendered_contents

Instance Method Summary collapse

Methods inherited from Base

#method_missing, #parse_metadata, #render, #respond_to_missing?, #write

Constructor Details

#initialize(site:, path:) ⇒ Post

Returns a new instance of Post.



7
8
9
# File 'lib/dimples/entries/post.rb', line 7

def initialize(site:, path:)
  super(site: site, source: Pathname.new(path))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dimples::Entries::Base

Instance Method Details

#output_directoryObject



11
12
13
14
15
16
# File 'lib/dimples/entries/post.rb', line 11

def output_directory
  @output_directory ||= File.dirname(@path).gsub(
    @site.config.source_paths[:posts],
    @site.config.build_paths[:posts]
  ).concat("/#{slug}/")
end

#slugObject



18
19
20
# File 'lib/dimples/entries/post.rb', line 18

def slug
  File.basename(@path, '.markdown')
end

#templateObject



22
23
24
# File 'lib/dimples/entries/post.rb', line 22

def template
  @template ||= Tilt::RedcarpetTemplate.new { @contents }
end