Sha256: f44b74093de49280b92a7e33f1f040265a81bfc16720fe6380522a23200708f6

Contents?: true

Size: 826 Bytes

Versions: 5

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

require 'zine/page'

module Zine
  # A page where the content comes from an array, usually an array of
  # links to other pages, eg an index page like the home page
  class DataPage < Zine::Page
    def initialize(data, templates, site_options, suffix = '.html')
      # super(front_matter, site_opt)
      init_templates(templates)
      @formatted_data = FormattedData.new({}, site_options)
      @formatted_data.page[:title] = data[:title]
      @formatted_data.data = data[:post_array]
      @dest_path = File.join(data[:build_dir],
                             Zine::Page.slug(data[:name]) + suffix)
      write
    end

    def write
      html = template_the_html
      compressor = HtmlCompressor::Compressor.new
      File.write(@dest_path, compressor.compress(html))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zine-0.21.0 lib/zine/data_page.rb
zine-0.20.0 lib/zine/data_page.rb
zine-0.19.0 lib/zine/data_page.rb
zine-0.18.0 lib/zine/data_page.rb
zine-0.17.0 lib/zine/data_page.rb