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
2
2
class React
3
3
class EntriesReactDevFilter < Docs ::EntriesFilter
4
4
def get_name
5
- canary_copy = '- This feature is available in the latest Canary'
6
5
name = at_css ( 'article h1' ) . content
7
- return name . sub ( canary_copy , ' (Canary)' )
6
+ return update_canary_copy ( name )
8
7
end
9
8
10
9
def get_type
11
10
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
13
18
is_learn_page = path . start_with? ( 'learn/' )
14
19
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)' )
16
26
end
17
27
end
18
28
end
You can’t perform that action at this time.
0 commit comments