Sha256: d35e0567b580f16b1490946668001228d786247083544dac7530d7ea8ab23e5d

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

module JekyllPush
  #
  #
  class Site
    attr_reader :baseurl, :dir
    #
    #
    def initialize(config = nil)
      @config   = config || config_from_file
      @baseurl  = @config.fetch 'baseurl', ''
      @dir      = compiled_site_dir
    end

    #
    #
    def config_from_file
      YAML.load_file "#{`pwd`.strip}/_config.yml"
    end

    #
    #
    def compiled_site_dir
      File.join `pwd`.strip, '_site'
    end

    # Rebuild the Jekyll site with @baseurl
    # @return [Nil]
    def rebuild
      FileUtils.rm_r @dir if File.directory? @dir
      opts = {
        destination: @dir,
        baseurl: @baseurl
      }
      opts['source'] = @config.dig 'source_dir' if @config.key? 'source'

      Jekyll::Site.new(Jekyll.configuration(opts)).process
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll_push-0.1.0 lib/jekyll_push/site.rb