[devdocsgjs/main: 28/239] Clean more elements




commit e17bbbf23ce3768cf9eb7991830a8c0bcbc752b3
Author: Kid <44045911+kidonng users noreply github com>
Date:   Mon Nov 29 03:43:16 2021 +0000

    Clean more elements

 lib/docs/filters/yarn/clean_html_berry.rb | 41 ++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/lib/docs/filters/yarn/clean_html_berry.rb b/lib/docs/filters/yarn/clean_html_berry.rb
index 00e0316c..5d901150 100644
--- a/lib/docs/filters/yarn/clean_html_berry.rb
+++ b/lib/docs/filters/yarn/clean_html_berry.rb
@@ -2,21 +2,40 @@ module Docs
   class Yarn
     class CleanHtmlBerryFilter < Filter
       def call
-        # Version notice
-        css('#gatsby-focus-wrapper > div').remove
+        if slug.empty?
+          @doc = at_css('main')
+          css(
+            (['div:first-child'] * 3).join('>'), # Tagline
+            'img',
+            'hr', # Footer
+            'hr + div', # Footer
+          ).remove
 
-        # Logo and menu
-        css('header > div:first-child').remove
+          css('a').each do |link|
+            link.name = 'div'
+            link.css('h3').each do |node|
+              node.replace("<h2><a href='#{link['href']}'>#{node.content}</a></h2>")
+            end
+          end
 
-        # Left nav and TOC
-        css('main > div > div:first-child', 'aside').remove
+          return doc
+        end
+
+        @doc = at_css('article')
+        # Heading & edit link
+        css('h1', 'h1 + a').remove unless slug.start_with?('configuration')
 
-        # Title and edit link
-        css('article > div:first-child').remove
+        if slug.start_with?('cli')
+          css('.header-code').each do |node|
+            node.name = 'span'
+          end
+        end
 
-        # Bottom divider on index
-        if slug == ''
-          css('main > hr').remove
+        if slug.start_with?('configuration')
+          css('h1', 'h2').each do |node|
+            node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
+            node.remove_attribute('style')
+          end
         end
 
         doc


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]