Module: Postnhost::NavigationHelper
- Defined in:
- app/helpers/postnhost/navigation_helper.rb
Instance Method Summary collapse
- #default_navigation_locale_key ⇒ Object
- #navigation_href(item) ⇒ Object
- #navigation_label(item) ⇒ Object
- #navigation_link_options(item) ⇒ Object
Instance Method Details
#default_navigation_locale_key ⇒ Object
32 33 34 |
# File 'app/helpers/postnhost/navigation_helper.rb', line 32 def @default_navigation_locale_key ||= @default_language&.html_lang || I18n.default_locale.to_s end |
#navigation_href(item) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/postnhost/navigation_helper.rb', line 15 def (item) return if item.blank? || item.kind != "link" @navigation_href_cache ||= {} cache_key = (item) return @navigation_href_cache[cache_key] if @navigation_href_cache.key?(cache_key) @navigation_href_cache[cache_key] = (item) end |
#navigation_label(item) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'app/helpers/postnhost/navigation_helper.rb', line 3 def (item) return if item.blank? @navigation_label_cache ||= {} cache_key = (item) return @navigation_label_cache[cache_key] if @navigation_label_cache.key?(cache_key) @navigation_label_cache[cache_key] = item.label_for(locale_key: @current_language&.html_lang, default_locale_key: ).presence || (item) end |
#navigation_link_options(item) ⇒ Object
25 26 27 28 29 30 |
# File 'app/helpers/postnhost/navigation_helper.rb', line 25 def (item) return {} unless item.target_kind == "external" rel_value = item.nofollow ? "noopener noreferrer nofollow" : "noopener noreferrer" { target: "_blank", rel: rel_value } end |