Sha256: c0bf8d5c52d13cb00dc6c402012f24f89154616c54e26a1a442efbac7a9f0711

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module Octodmin
  class Site
    attr_accessor :site

    DEFAULT_CONFIG = {
      "octodmin" => {
        "transliterate" => "latin",
        "front_matter" => {
          "layout" => {
            "type" => "text",
          },
          "title" => {
            "type" => "text",
          },
          "slug" => {
            "type" => "text",
          },
          "date" => {
            "type" => "text",
          },
        },
      },
    }

    def initialize
      @site = Jekyll::Site.new(Jekyll.configuration)
    end

    def source
      @site.source
    end

    def config
      @config ||= Jekyll::Utils.deep_merge_hashes(DEFAULT_CONFIG, @site.config)
    end

    def serializable_hash
      config
    end

    def posts
      reset
      @site.read
      @site.posts.sort_by(&:date).last(20).reverse.map { |post| Post.new(self, post) }
    end

    def reset
      @status = nil
      @site.reset
      self
    end

    def status
      @status ||= Git.open(Octodmin::App.dir).status
    end

    def process
      @site.process
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
octodmin-0.3.5 lib/octodmin/site.rb
octodmin-0.3.4 lib/octodmin/site.rb
octodmin-0.3.3 lib/octodmin/site.rb
octodmin-0.3.2 lib/octodmin/site.rb