class ExtendController
Public Instance Methods
index()
click to toggle source
# File lib/nexmo_developer/app/controllers/extend_controller.rb, line 4 def index document_paths = Dir.glob("#{Rails.configuration.docs_base_path}/_extend/**/*.md") @extensions = document_paths.map do |document_path| document = File.read(document_path) frontmatter = YAML.safe_load(document) next unless frontmatter['published'] title = frontmatter['title'] description = frontmatter['description'] tags = frontmatter['tags'] || [] image = frontmatter['image'] || '' route = File.basename(document_path, '.*') { title: title, description: description, tags: tags, image: image, route: route } end.compact render layout: 'landing' end
show()
click to toggle source
# File lib/nexmo_developer/app/controllers/extend_controller.rb, line 23 def show document_path = "#{Rails.configuration.docs_base_path}/_extend/#{params[:title]}.md" document = File.read(document_path) body = Nexmo::Markdown::Renderer.new.call(document) frontmatter = YAML.safe_load(document) title = frontmatter['title'] description = frontmatter['description'] tags = frontmatter['tags'] || [] image = frontmatter['image'] || '' cta = frontmatter['cta'] || 'Use This' link = frontmatter['link'] || '' @extension = { title: title, body: body, image: image, description: description, tags: tags, link: link, cta: cta } render layout: 'page' end