Sha256: 7e88800704f06fd361566d747ea4825213224f9b8f26047437630277e15c98d8
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Bridgetown module Resource class Destination # @return [Bridgetown::Resource::Base] attr_accessor :resource # @return [String] attr_accessor :output_ext # @param resource [Bridgetown::Resource::Base] def initialize(resource) @resource = resource @output_ext = resource.transformer.final_ext end def absolute_url Addressable::URI.parse( resource.site.config.url.to_s + relative_url ).normalize.to_s end def relative_url @processor ||= PermalinkProcessor.new(resource) @processor.transform end def final_ext output_ext || resource.extname end def output_path path = URL.unescape_path(relative_url) path = path.delete_prefix(resource.site.baseurl) if resource.site.baseurl.present? path = resource.site.in_dest_dir(path) path = File.join(path, "index.html") if relative_url.end_with? "/" path end def write(output) path = output_path FileUtils.mkdir_p(File.dirname(path)) Bridgetown.logger.debug "Writing:", path File.write(path, output, mode: "wb") end end end end
Version data entries
6 entries across 6 versions & 1 rubygems