Explorar o código

get nextjs types by subpath, removed the sticky menu

Yen Ton hai 1 ano
pai
achega
a1d4f87fc4
Modificáronse 2 ficheiros con 27 adicións e 10 borrados
  1. 2 1
      lib/docs/filters/nextjs/clean_html.rb
  2. 25 9
      lib/docs/filters/nextjs/entries.rb

+ 2 - 1
lib/docs/filters/nextjs/clean_html.rb

@@ -3,9 +3,10 @@ module Docs
         class CleanHtmlFilter < Filter
             def call
                 css('.zola-anchor').remove
-                doc.prepend_child("<h1>NextJS</h1>") if root_page?
+                doc.prepend_child("<h1>NextJS2</h1>") if root_page?
                 css('div:contains("NEWS:")').remove
                 css('h2:contains("sponsors"), #sponsor-table').remove
+                css('div.sticky').remove #remove the floating menu
                 doc
             end
         end

+ 25 - 9
lib/docs/filters/nextjs/entries.rb

@@ -1,13 +1,29 @@
 module Docs
-    class Nextjs
-        class EntriesFilter < Docs::EntriesFilter
-            def get_name
-              at_css('h1').content
-            end
+  class Nextjs
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content
+        name.strip!
+        name
+      end
 
-            def get_type
-                get_name
-            end
+      def get_type
+        if subpath.include?('/architecture')
+          'Architecture'
+        elsif subpath.include?('/community')
+          'Community'
+        elsif subpath.include?('/getting-started')
+          'Getting Started'
+        elsif subpath.include?('/messages')
+          'Messages'
+        elsif subpath.include?('/app')
+          'Using App Router'
+        elsif subpath.include?('/pages')
+          'Using Pages Router'
+        else
+          get_name
         end
+      end
     end
-end
+  end
+end