[devdocsgjs/main: 182/239] Adjust the tailwind entries generator to support tailwind 3




commit 268441f33be8b34ffee7c212536db42b0f324d08
Author: IgnusG <6438760+IgnusG users noreply github com>
Date:   Mon Feb 21 21:39:29 2022 +0100

    Adjust the tailwind entries generator to support tailwind 3

 lib/docs/filters/tailwindcss/entries.rb | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/lib/docs/filters/tailwindcss/entries.rb b/lib/docs/filters/tailwindcss/entries.rb
index 4e8e8786..ad0bf7b4 100644
--- a/lib/docs/filters/tailwindcss/entries.rb
+++ b/lib/docs/filters/tailwindcss/entries.rb
@@ -2,16 +2,22 @@ module Docs
   class Tailwindcss
     class EntriesFilter < Docs::EntriesFilter
       def get_type
-        # /customizing-colors rediects to /colors, hence making css
-        # selector below not to match the href
-        if result[:path] == 'customizing-colors'
-          selector = "#sidebar a[href='#{result[:path]}']"
-        else
-          selector = "#sidebar a[href='#{result[:path]}']"
-        end
+        # We are only interested in children list items
+        selector = "nav li li a[href='#{result[:path]}']"
 
-        check = at_css(selector).parent.parent.parent.css('h5').inner_text
-        check
+        anchor = at_css(selector)
+        category_list = anchor.ancestors('li')[1]
+        title = category_list.css('h5')
+
+        return title.inner_text
+      end
+
+      def get_name
+        # We are only interested in children list items
+        selector = "nav li li a[href='#{result[:path]}']"
+        item = at_css(selector)
+
+        return item.inner_text
       end
     end
   end


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