Sha256: 5d957670961f1a29089af19a96aba51e65c25260e5fdd52f2b25ad1253988c45

Contents?: true

Size: 736 Bytes

Versions: 5

Compression:

Stored size: 736 Bytes

Contents

module Nesta
  module Static
    class HtmlFile
      def initialize(build_dir, page)
        @build_dir = build_dir
        @content_path = page.filename
      end

      def page_shares_path_with_directory?(dir, base_without_ext)
        Dir.exist?(File.join(dir, base_without_ext))
      end

      def filename
        dir, base = File.split(@content_path)
        base_without_ext = File.basename(base, File.extname(base))
        subdir = dir.sub(/^#{Nesta::Config.page_path}/, '')
        path = File.join(@build_dir, subdir, base_without_ext)
        if page_shares_path_with_directory?(dir, base_without_ext)
          File.join(path, 'index.html')
        else
          path + '.html'
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nesta-0.18.0 lib/nesta/static/html_file.rb
nesta-0.17.0 lib/nesta/static/html_file.rb
nesta-0.16.0 lib/nesta/static/html_file.rb
nesta-0.15.0 lib/nesta/static/html_file.rb
nesta-0.14.0 lib/nesta/static/html_file.rb