Unified · Split
| @@ -6,7 +6,9 @@ module Docs · 5 unmodified lines | ||
| 6 | 6 | |
| 7 | 7 | # Remove breadcrumbs before h1 |
| 8 | 8 | css('h1').each do |node| |
| 9 | − node.previous.remove | |
| 9 | + if (node.previous) | |
| 10 | + node.previous.remove | |
| 11 | + end | |
| 10 | 12 | end |
| 11 | 13 | |
| 12 | 14 | remove_selectors = [ |
| @@ -4,12 +4,15 @@ module Docs · 3 unmodified lines | ||
| 4 | 4 | def get_name |
| 5 | 5 | canary_copy = '- This feature is available in the latest Canary' |
| 6 | 6 | name = at_css('article h1').content |
| 7 | − return name.sub(canary_copy, ' (Experimental)') | |
| 7 | + return name.sub(canary_copy, ' (Canary)') | |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | 10 | def get_type |
| 11 | 11 | breadcrumb_nodes = css('a.tracking-wide') |
| 12 | − return breadcrumb_nodes.last.content || 'Miscellaneous' | |
| 12 | + category = breadcrumb_nodes.last.content | |
| 13 | + is_learn_page = base_url.to_s.end_with?('learn') | |
| 14 | + prefix = is_learn_page ? 'Learn: ' : '' | |
| 15 | + return prefix + (category || 'Miscellaneous') | |
| 13 | 16 | end |
| 14 | 17 | end |
| 15 | 18 | end |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class React < UrlScraper |
| 3 | + include MultipleBaseUrls | |
| 4 | + | |
| 3 | 5 | self.name = 'React' |
| 4 | 6 | self.type = 'simple' |
| 5 | 7 | self.links = { |
| @@ -9,8 +11,12 @@ module Docs · 3 unmodified lines | ||
| 9 | 11 | |
| 10 | 12 | version do |
| 11 | 13 | self.release = '18.3.1' |
| 12 | − # TODO add /learn | |
| 13 | − self.base_url = 'https://react.dev/reference' | |
| 14 | + host = 'https://react.dev' | |
| 15 | + self.base_urls = [ | |
| 16 | + "#{host}/reference", | |
| 17 | + "#{host}/learn", | |
| 18 | + ] | |
| 19 | + self.initial_paths = %w(/react) | |
| 14 | 20 | |
| 15 | 21 | html_filters.push 'react/entries_react_dev', 'react/clean_html_react_dev' |
| 16 | 22 | |