Sha256: 41aab111afdf7e5913c9d9afbd0d187299533fd2ce26e64908269fe35e3ddca5
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
module GovukPublishingComponents class ComponentGuideController < GovukPublishingComponents::ApplicationController append_view_path File.join(Rails.root, "app", "views", "components") def index @component_docs = component_documentation_resolver.all end def show @component_doc = component_documentation_resolver.get(params[:component]) @guide_breadcrumbs = [index_breadcrumb, component_breadcrumb(@component_doc)] end def example @component_doc = component_documentation_resolver.get(params[:component]) @component_example = @component_doc.examples.find { |f| f.id == params[:example] } @guide_breadcrumbs = [ index_breadcrumb, component_breadcrumb(@component_doc, @component_example), { title: @component_example.name } ] end def preview @component_examples = [] @component_doc = component_documentation_resolver.get(params[:component]) @preview = true if params[:example].present? @component_examples.push(@component_doc.examples.find { |f| f.id == params[:example] }) else @component_examples = @component_doc.examples end end private def component_documentation_resolver @component_documentation_resolver ||= ComponentDocResolver.new end def index_breadcrumb { title: GovukPublishingComponents::Config.component_guide_title, url: component_guide_path } end def component_breadcrumb(component_doc, component_example = nil) Hash.new.tap do |h| h[:title] = component_doc.name h[:url] = component_doc_path(component_doc.id) if component_example end end end end
Version data entries
2 entries across 2 versions & 1 rubygems