vagrant/website/config.rb

69 lines
1.6 KiB
Ruby
Raw Normal View History

set :base_url, "https://www.vagrantup.com/"
activate :hashicorp do |h|
h.name = "vagrant"
2017-02-28 15:44:38 +00:00
h.version = "1.9.2"
h.github_slug = "mitchellh/vagrant"
end
helpers do
# This helps by setting the "active" class for sidebar nav elements
# if the YAML frontmatter matches the expected value.
def sidebar_current(expected)
current = current_page.data.sidebar_current || ""
if current.start_with?(expected)
return " class=\"active\""
else
return ""
end
end
# This returns the overall section of the documentation we're on.
def sidebar_section
current = current_page.data.sidebar_current
return "" if !current
current.split("-")[0]
end
def body_classes
classify = ->(s) { s.downcase.gsub(/[^a-zA-Z0-9]/, "-").squeeze("-") }
classes = []
if current_page.data.page_title
classes << "page-#{classify.call(current_page.data.page_title)}"
else
classes << "page-home"
end
if current_page.data.layout
classes << "layout-#{classify.call(current_page.data.layout)}"
end
return classes.join(" ")
end
# "home layout-#{current_page.data.layout}"
# Get the title for the page.
#
# @param [Middleman::Page] page
#
# @return [String]
def title_for(page)
if page && page.data.page_title
return "#{page.data.page_title} - Vagrant by HashiCorp"
end
"Vagrant by HashiCorp"
end
2016-10-22 04:38:53 +00:00
# Get the description for the page
#
# @param [Middleman::Page] page
#
# @return [String]
def description_for(page)
return escape_html(current_page.data.description || "")
end
end