Sha256: 57b4b30931aa6d6dca2a83afceeabeffce0cb90aa53dd407510dd7fd1ccb5f87

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 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(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

5 entries across 5 versions & 1 rubygems

Version Path
octodmin-0.3.1 lib/octodmin/site.rb
octodmin-0.3.0 lib/octodmin/site.rb
octodmin-0.2.1 lib/octodmin/site.rb
octodmin-0.2.0 lib/octodmin/site.rb
octodmin-0.1.0 lib/octodmin/site.rb