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
22 class Yarn
33 class CleanHtmlBerryFilter < Filter
44 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
713
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
1020
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')
1327
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
1633
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
2039 end
2140
2241 doc