Address top-level page categories

pull/2375/head
Gergely Gombos 2 months ago
parent 7be6b3e7c4
commit 2e1f0a0462

@ -2,17 +2,27 @@ module Docs
class React
class EntriesReactDevFilter < Docs::EntriesFilter
def get_name
canary_copy = '- This feature is available in the latest Canary'
name = at_css('article h1').content
return name.sub(canary_copy, ' (Canary)')
return update_canary_copy(name)
end
def get_type
breadcrumb_nodes = css('a.tracking-wide')
category = breadcrumb_nodes.last.content
is_top_level_page = breadcrumb_nodes.length == 1
category = if is_top_level_page
# Category is the opened category in the sidebar
css('aside a.text-link div').first.content
else
breadcrumb_nodes.last.content
end
is_learn_page = path.start_with?('learn/')
prefix = is_learn_page ? 'Learn: ' : ''
return prefix + (category || 'Miscellaneous')
return update_canary_copy(prefix + (category || 'Miscellaneous'))
end
def update_canary_copy(string)
canary_copy = '- This feature is available in the latest Canary'
return string.sub(canary_copy, ' (Canary)')
end
end
end

Loading…
Cancel
Save