add Learn pages

pull/2375/head
Gergely Gombos 2 months ago
parent df398bd145
commit fefde4e15b

@ -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 = [

@ -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

@ -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'

Loading…
Cancel
Save