Sha256: f5bc6ec7aab132cfa9ca261f348704d66a3c617d2edbf445e0a1f3b2296a17a4

Contents?: true

Size: 825 Bytes

Versions: 3

Compression:

Stored size: 825 Bytes

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"]
          alias_url = resource.data["alias"]
          alias_url += "index.html" if alias_url.match(/\/$/)
          resources.push Middleman::Sitemap::AliasResource.new(@app.sitemap, alias_url, resource.url)
          #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
      resources
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
middleman-alias-0.0.7 lib/middleman-alias/extension.rb
middleman-alias-0.0.6 lib/middleman-alias/extension.rb
middleman-alias-0.0.5 lib/middleman-alias/extension.rb