Sha256: d6e403859d4cac2345d1540d9bf04b125271e944b22e14a3aba6412ef48e78aa

Contents?: true

Size: 426 Bytes

Versions: 2

Compression:

Stored size: 426 Bytes

Contents

# frozen_string_literal: true

module Staticky
  Resource = Data.define(:url, :component) do
    def full_filepath
      Staticky.build_path.join(filepath)
    end

    def read
      full_filepath.read
    end

    def filepath
      root? ? "index.html" : "#{url}.html"
    end

    def root?
      url == "/"
    end

    def build(view_context: ViewContext.new(self))
      component.call(view_context:)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
staticky-0.1.1 lib/staticky/resource.rb
staticky-0.1.0 lib/staticky/resource.rb