Better headers

pull/840/head
Jasper van Merle 7 years ago
parent 14cf0582c3
commit b51d4e50d6

@ -10,6 +10,25 @@ module Docs
at_css('.main-content').prepend_child("<h1>#{name} #{kind}</h1>")
end
# Add a title to the homepage of the v2 docs
if subpath == 'index.html' && at_css('.main-content > h1').nil?
at_css('.main-content').prepend_child('<h1>Dart SDK</h1>')
end
# Add the library to the main content (it is not always visible in the menu entry)
breadcrumbs = at_css('.breadcrumbs').css('li:not(.self-crumb) > a')
if breadcrumbs.length > 1
library = breadcrumbs[1].content
# Generate the link to the homepage of the library
with_hypens = library.gsub(/:/, '-')
location = "#{'../' * subpath.count('/')}#{with_hypens}/#{with_hypens}-library"
link = "<a href=\"#{location}\" class=\"_links-link\">#{library}</span>"
# Add the link to the main title, just like how the "Homepage" and "Source code" links appear
at_css('.main-content').prepend_child("<p class=\"_links\">#{link}</p>")
end
# Extract the actual content
# We can't use options[:container] here because the entries filter uses the breadcrumbs node
@doc = at_css('.main-content')

Loading…
Cancel
Save