History

use better top-level categories

Gergely Gombos committed 1 year ago

Commit 94a7aa31 parent 7a510f62 files · +12 −14Browse files

Unified · Split

2 files
  1. lib/docs/filters/react/clean_html_react_dev.rb +1 −3
  2. lib/docs/filters/react/entries_react_dev.rb +11 −11
lib/docs/filters/react/clean_html_react_dev.rb+1−3
@@ -31,9 +31,7 @@ module Docs · 30 unmodified lines
31 end31 end
32 32
33 # Remove styling divs while lifting children33 # Remove styling divs while lifting children
34 styling_prefixes = [34 styling_prefixes = %w[ps- mx- my- px- py- mb- sp- rounded-]
35 'ps-', 'mx-', 'my-', 'px-', 'py-', 'mb-', 'sp-', 'rounded-'
36 ]
37 selectors = styling_prefixes.map { |prefix| "div[class*=\"#{prefix}\"]" }35 selectors = styling_prefixes.map { |prefix| "div[class*=\"#{prefix}\"]" }
38 css(*selectors, 'div[class=""]', 'div.cm-line').each do |node|36 css(*selectors, 'div[class=""]', 'div.cm-line').each do |node|
39 node.before(node.children).remove37 node.before(node.children).remove
lib/docs/filters/react/entries_react_dev.rb+11−11
@@ -2,21 +2,21 @@ module Docs · 1 unmodified line
2 class React2 class React
3 class EntriesReactDevFilter < Docs::EntriesFilter3 class EntriesReactDevFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 name = at_css('article h1').content5 name = at_css('article h1')&.content
6 return update_canary_copy(name)6 return update_canary_copy(name)
7 end7 end
8 8
9 def get_type9 def get_type
10 breadcrumb_nodes = css('a.tracking-wide')10 # Category is the opened category in the sidebar
11 is_top_level_page = breadcrumb_nodes.length == 111 category = css('a:has(> span.text-link) > div').first&.content
12 category = if is_top_level_page12 # The grey category in the sidebar
13 # Category is the opened category in the sidebar13 top_category = css('h3:has(~ li a.text-link)')
14 css('aside a.text-link div').first.content14 .last&.content
15 else15 &.sub(/@.*$/, '') # remove version tag
16 breadcrumb_nodes.last.content16 &.sub(/^./, &:upcase) # capitalize first letter
17 end17 &.concat(": ")
18 is_learn_page = path.start_with?('learn/')18 is_learn_page = path.start_with?('learn/') || slug == 'learn'
19 prefix = is_learn_page ? 'Learn: ' : ''19 prefix = is_learn_page ? 'Learn: ' : top_category
20 return update_canary_copy(prefix + (category || 'Miscellaneous'))20 return update_canary_copy(prefix + (category || 'Miscellaneous'))
21 end21 end
22 22

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t