Unified · Split
| @@ -2,21 +2,40 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Yarn |
| 3 | 3 | class CleanHtmlBerryFilter < Filter |
| 4 | 4 | def call |
| 5 | − # Version notice | |
| 6 | − css('#gatsby-focus-wrapper > div').remove | |
| 5 | + if slug.empty? | |
| 6 | + @doc = at_css('main') | |
| 7 | + css( | |
| 8 | + (['div:first-child'] * 3).join('>'), # Tagline | |
| 9 | + 'img', | |
| 10 | + 'hr', # Footer | |
| 11 | + 'hr + div', # Footer | |
| 12 | + ).remove | |
| 7 | 13 | |
| 8 | − # Logo and menu | |
| 9 | − css('header > div:first-child').remove | |
| 14 | + css('a').each do |link| | |
| 15 | + link.name = 'div' | |
| 16 | + link.css('h3').each do |node| | |
| 17 | + node.replace("<h2><a href='#{link['href']}'>#{node.content}</a></h2>") | |
| 18 | + end | |
| 19 | + end | |
| 10 | 20 | |
| 11 | − # Left nav and TOC | |
| 12 | − css('main > div > div:first-child', 'aside').remove | |
| 21 | + return doc | |
| 22 | + end | |
| 23 | + | |
| 24 | + @doc = at_css('article') | |
| 25 | + # Heading & edit link | |
| 26 | + css('h1', 'h1 + a').remove unless slug.start_with?('configuration') | |
| 13 | 27 | |
| 14 | − # Title and edit link | |
| 15 | − css('article > div:first-child').remove | |
| 28 | + if slug.start_with?('cli') | |
| 29 | + css('.header-code').each do |node| | |
| 30 | + node.name = 'span' | |
| 31 | + end | |
| 32 | + end | |
| 16 | 33 | |
| 17 | − # Bottom divider on index | |
| 18 | − if slug == '' | |
| 19 | − css('main > hr').remove | |
| 34 | + if slug.start_with?('configuration') | |
| 35 | + css('h1', 'h2').each do |node| | |
| 36 | + node.name = node.name.sub(/\d/) { |i| i.to_i + 1 } | |
| 37 | + node.remove_attribute('style') | |
| 38 | + end | |
| 20 | 39 | end |
| 21 | 40 | |
| 22 | 41 | doc |