Sha256: 9455b58ec1fc57fd7ae6a2f124fddfdb5c62518ec3c074a593da09671ad40ded

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

require 'brite/page'

module Brite

  # Models a blog post. A post is essentially  the same as a page,
  # but carries a relatition with other posts that a page does not.
  #
  class Post < Page

    #
    def initialize_defaults
      super

      @route  = site.config.post_route
      @layout = site.config.post_layout #@site.config.find_layout(@site.config.post_layout)

      @previous_post = nil
      @next_post     = nil
    end

    # This assumes `site.posts` is sorted by date.
    #
    # @todo Rename to back_post.
    def previous_post
      @previous_post ||= (
        index = site.posts.index(self)
        index == 0 ? nil : site.posts[index - 1]
      )
    end

    # This assumes `site.posts` is sorted by date.
    def next_post
      @next_post ||= (
        index = site.posts.index(self)
        site.posts[index + 1]
      )
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brite-0.7.0 lib/brite/post.rb