File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,27 @@ module Docs
22 class React
33 class EntriesReactDevFilter < Docs ::EntriesFilter
44 def get_name
5- canary_copy = '- This feature is available in the latest Canary'
65 name = at_css ( 'article h1' ) . content
7- return name . sub ( canary_copy , ' (Canary)' )
6+ return update_canary_copy ( name )
87 end
98
109 def get_type
1110 breadcrumb_nodes = css ( 'a.tracking-wide' )
12- category = breadcrumb_nodes . last . content
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
1318 is_learn_page = path . start_with? ( 'learn/' )
1419 prefix = is_learn_page ? 'Learn: ' : ''
15- return prefix + ( category || 'Miscellaneous' )
20+ return update_canary_copy ( prefix + ( category || 'Miscellaneous' ) )
21+ end
22+
23+ def update_canary_copy ( string )
24+ canary_copy = '- This feature is available in the latest Canary'
25+ return string . sub ( canary_copy , ' (Canary)' )
1626 end
1727 end
1828 end
You can’t perform that action at this time.
0 commit comments