Sha256: 672923d831d0eaf5549103006a22803b26f7b59d6270c5668c71bbb34cc71df9
Contents?: true
Size: 927 Bytes
Versions: 18
Compression:
Stored size: 927 Bytes
Contents
module Lookbook module PageHelper include Utils def page_path(id) page = id.is_a?(Page) ? id : Lookbook.pages.find(id) if page.present? lookbook_page_path page.lookup_path else Lookbook.logger.warn "Could not find page with id ':#{id}'" end end def embed(*args, params: {}, type: :preview, max_height: nil, **opts) return unless args.any? @embed_counter ||= 0 preview_lookup = args.first.is_a?(Symbol) ? args.first : preview_class_path(args.first) preview = Lookbook.previews.find(preview_lookup) example = args[1] ? preview&.example(args[1]) : preview&.default_example embed_id = "#{url_for}/embed/#{example.lookup_path}".delete_prefix("/").tr("/", "-") render_component :embed, id: embed_id, example: example, params: params, max_height: max_height, opts: opts end end end
Version data entries
18 entries across 18 versions & 1 rubygems