Skip to content

Commit 2e1f0a0

Browse files
committed
Address top-level page categories
1 parent 7be6b3e commit 2e1f0a0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lib/docs/filters/react/entries_react_dev.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)