History

Clean more elements

Kid committed 4 years ago

Commit e17bbbf1 parent 19d6edf1 file · +30 −11Browse files

Unified · Split

lib/docs/filters/yarn/clean_html_berry.rb+30−11
@@ -2,21 +2,40 @@ module Docs · 1 unmodified line
2 class Yarn2 class Yarn
3 class CleanHtmlBerryFilter < Filter3 class CleanHtmlBerryFilter < Filter
4 def call4 def call
5 # Version notice5 if slug.empty?
6 css('#gatsby-focus-wrapper > div').remove6 @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 menu14 css('a').each do |link|
9 css('header > div:first-child').remove15 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 TOC21 return doc
12 css('main > div > div:first-child', 'aside').remove22 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 link28 if slug.start_with?('cli')
15 css('article > div:first-child').remove29 css('.header-code').each do |node|
30 node.name = 'span'
31 end
32 end
16 33
17 # Bottom divider on index34 if slug.start_with?('configuration')
18 if slug == ''35 css('h1', 'h2').each do |node|
19 css('main > hr').remove36 node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
37 node.remove_attribute('style')
38 end
20 end39 end
21 40
22 doc41 doc