diff --git a/lib/docs/filters/react/clean_html_react_dev.rb b/lib/docs/filters/react/clean_html_react_dev.rb
index dc9dcae1..954dd9b3 100644
--- a/lib/docs/filters/react/clean_html_react_dev.rb
+++ b/lib/docs/filters/react/clean_html_react_dev.rb
@@ -6,7 +6,9 @@ module Docs
# Remove breadcrumbs before h1
css('h1').each do |node|
- node.previous.remove
+ if (node.previous)
+ node.previous.remove
+ end
end
remove_selectors = [
diff --git a/lib/docs/filters/react/entries_react_dev.rb b/lib/docs/filters/react/entries_react_dev.rb
index 0c49a6d8..0fda0c5a 100644
--- a/lib/docs/filters/react/entries_react_dev.rb
+++ b/lib/docs/filters/react/entries_react_dev.rb
@@ -4,12 +4,15 @@ module Docs
def get_name
canary_copy = '- This feature is available in the latest Canary'
name = at_css('article h1').content
- return name.sub(canary_copy, ' (Experimental)')
+ return name.sub(canary_copy, ' (Canary)')
end
def get_type
breadcrumb_nodes = css('a.tracking-wide')
- return breadcrumb_nodes.last.content || 'Miscellaneous'
+ category = breadcrumb_nodes.last.content
+ is_learn_page = base_url.to_s.end_with?('learn')
+ prefix = is_learn_page ? 'Learn: ' : ''
+ return prefix + (category || 'Miscellaneous')
end
end
end
diff --git a/lib/docs/scrapers/react.rb b/lib/docs/scrapers/react.rb
index 02133b17..a24798da 100644
--- a/lib/docs/scrapers/react.rb
+++ b/lib/docs/scrapers/react.rb
@@ -1,5 +1,7 @@
module Docs
class React < UrlScraper
+ include MultipleBaseUrls
+
self.name = 'React'
self.type = 'simple'
self.links = {
@@ -9,8 +11,12 @@ module Docs
version do
self.release = '18.3.1'
- # TODO add /learn
- self.base_url = 'https://react.dev/reference'
+ host = 'https://react.dev'
+ self.base_urls = [
+ "#{host}/reference",
+ "#{host}/learn",
+ ]
+ self.initial_paths = %w(/react)
html_filters.push 'react/entries_react_dev', 'react/clean_html_react_dev'