Sha256: f6bf131c15a729a5d7ae25aa6c7c7617d53d6bcf9db396eb4f693c939b7d4a89
Contents?: true
Size: 865 Bytes
Versions: 1
Compression:
Stored size: 865 Bytes
Contents
# frozen_string_literal: true class WCC::Contentful::Model::MenuButton < WCC::Contentful::Model def external_uri @external_url ||= URI(external_link) if external_link.present? end # A menu link is external if `external_link` is present and not relative. def external? external_uri&.scheme.present? end # Gets either the external link or the slug from the referenced page. # Example usage: `<%= link_to button.title, button.href %>` def href return external_link if external_link url = (link&.try(:slug) || link&.try(:url)) url = URI(url || '') url.path = "/#{sys.locale}#{url.path}" if sys.locale != WCC::Contentful.configuration.default_locale url.fragment = fragment if fragment.present? url.to_s end def fragment WCC::Contentful::App::SectionHelper.section_id(section_link) if section_link end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wcc-contentful-app-1.4.0.rc1 | lib/wcc/contentful/model/menu_button.rb |