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
3131 end
3232
3333 # Remove styling divs while lifting children
34− styling_prefixes = [
35− 'ps-', 'mx-', 'my-', 'px-', 'py-', 'mb-', 'sp-', 'rounded-'
36− ]
34+ styling_prefixes = %w[ps- mx- my- px- py- mb- sp- rounded-]
3735 selectors = styling_prefixes.map { |prefix| "div[class*=\"#{prefix}\"]" }
3836 css(*selectors, 'div[class=""]', 'div.cm-line').each do |node|
3937 node.before(node.children).remove
lib/docs/filters/react/entries_react_dev.rb+11−11
@@ -2,21 +2,21 @@ module Docs · 1 unmodified line
22 class React
33 class EntriesReactDevFilter < Docs::EntriesFilter
44 def get_name
5− name = at_css('article h1').content
5+ name = at_css('article h1')&.content
66 return update_canary_copy(name)
77 end
88
99 def get_type
10− breadcrumb_nodes = css('a.tracking-wide')
11− is_top_level_page = breadcrumb_nodes.length == 1
12− category = if is_top_level_page
13− # Category is the opened category in the sidebar
14− css('aside a.text-link div').first.content
15− else
16− breadcrumb_nodes.last.content
17− end
18− is_learn_page = path.start_with?('learn/')
19− prefix = is_learn_page ? 'Learn: ' : ''
10+ # Category is the opened category in the sidebar
11+ category = css('a:has(> span.text-link) > div').first&.content
12+ # The grey category in the sidebar
13+ top_category = css('h3:has(~ li a.text-link)')
14+ .last&.content
15+ &.sub(/@.*$/, '') # remove version tag
16+ &.sub(/^./, &:upcase) # capitalize first letter
17+ &.concat(": ")
18+ is_learn_page = path.start_with?('learn/') || slug == 'learn'
19+ prefix = is_learn_page ? 'Learn: ' : top_category
2020 return update_canary_copy(prefix + (category || 'Miscellaneous'))
2121 end
2222

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