Sha256: 0095b75b696b129d909e4a9706596a9069bede7c9379a638e21a51e814861b48

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

require 'middleman-core'
require 'middleman-alias/alias-resource'

module Middleman
  class AliasExtension < Middleman::Extension
    def initialize(app, options_hash={}, &block)
      super
    end

    def manipulate_resource_list(resources)
      resources.each do |resource|
        if resource.data["alias"]
          Array(resource.data["alias"]).each do |mm_alias|
            alias_url = mm_alias
            alias_url += "index.html" if alias_url.match(/\/$/)
            existing_resource = resources.select{|r| r.destination_path == alias_url }.first
            next if existing_resource

            resources.push Middleman::Sitemap::AliasResource.new(@app.sitemap, alias_url, resource)
            #Sitemap::Resource.new(@app.sitemap, alias_url).tap do |p|
              #p.proxy_to("alias.html")
              #p.add_metadata locals: {
                #destination: resource.url
              #}
              #resources.push p
            #end
          end
        end
      end
      resources
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
middleman-alias-0.0.17 lib/middleman-alias/extension.rb
middleman-alias-0.0.16 lib/middleman-alias/extension.rb
middleman-alias-0.0.15 lib/middleman-alias/extension.rb
middleman-alias-0.0.14 lib/middleman-alias/extension.rb
middleman-alias-0.0.13 lib/middleman-alias/extension.rb
middleman-alias-0.0.12 lib/middleman-alias/extension.rb