Sha256: 0333e724323f111b808780ddf044da1b65cbea8e2fabdd2c8de1118653e168d0

Contents?: true

Size: 606 Bytes

Versions: 2

Compression:

Stored size: 606 Bytes

Contents

require "middleman-core"

class AriaCurrent < ::Middleman::Extension
  FILE_EXTENSION = /\.(\w*)$/

  helpers do
    def current_link_to(*arguments, aria_current: "page", **options, &block)
      if block_given?
        text = capture(&block)
        path = arguments[0]
      else
        text = arguments[0]
        path = arguments[1]
      end

      link_options = options
      current_path = current_page.url.to_s.gsub(FILE_EXTENSION, "")

      if current_path == path
        link_options.merge!("aria-current" => aria_current)
      end

      link_to(text, path, link_options)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-aria_current-0.1.1 lib/middleman-aria_current/extension.rb
middleman-aria_current-0.1.0 lib/middleman-aria_current/extension.rb