This way screen reader users will be notified that the element is the current one. I'm not entirely sure whether `aria-current="page"` is more appropriate than `aria-current="true"`, since it's a general helper which can be used for any collection of links.
14 lines
341 B
Ruby
14 lines
341 B
Ruby
module LinkListHelper
|
|
def link_list(*links, **options)
|
|
return "" if links.compact.empty?
|
|
|
|
tag.ul(options) do
|
|
safe_join(links.compact.map do |text, url, current = false, **link_options|
|
|
tag.li(({ "aria-current": true } if current)) do
|
|
link_to text, url, link_options
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
end
|