Unified · Split
| @@ -2,21 +2,40 @@ module Docs · 1 unmodified line | |||
| 2 | class Yarn | 2 | class Yarn |
| 3 | class CleanHtmlBerryFilter < Filter | 3 | class CleanHtmlBerryFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | # Version notice | 5 | if slug.empty? |
| 6 | css('#gatsby-focus-wrapper > div').remove | 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 | 14 | css('a').each do |link| |
| 9 | css('header > div:first-child').remove | 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 | 21 | return doc |
| 12 | css('main > div > div:first-child', 'aside').remove | 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 | 28 | if slug.start_with?('cli') |
| 15 | css('article > div:first-child').remove | 29 | css('.header-code').each do |node| |
| 30 | node.name = 'span' | ||
| 31 | end | ||
| 32 | end | ||
| 16 | 33 | ||
| 17 | # Bottom divider on index | 34 | if slug.start_with?('configuration') |
| 18 | if slug == '' | 35 | css('h1', 'h2').each do |node| |
| 19 | css('main > hr').remove | 36 | node.name = node.name.sub(/\d/) { |i| i.to_i + 1 } |
| 37 | node.remove_attribute('style') | ||
| 38 | end | ||
| 20 | end | 39 | end |
| 21 | 40 | ||
| 22 | doc | 41 | doc |