From 33aba064c175c61274c329033cc64cc39b85aef8 Mon Sep 17 00:00:00 2001 From: Gergely Gombos Date: Sun, 1 Dec 2024 23:18:53 +0100 Subject: [PATCH] use single base URL for working crosslinks --- lib/docs/filters/react/entries_react_dev.rb | 2 +- lib/docs/scrapers/react.rb | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/docs/filters/react/entries_react_dev.rb b/lib/docs/filters/react/entries_react_dev.rb index 0fda0c5a..358d6a8d 100644 --- a/lib/docs/filters/react/entries_react_dev.rb +++ b/lib/docs/filters/react/entries_react_dev.rb @@ -10,7 +10,7 @@ module Docs def get_type breadcrumb_nodes = css('a.tracking-wide') category = breadcrumb_nodes.last.content - is_learn_page = base_url.to_s.end_with?('learn') + is_learn_page = path.start_with?('learn/') prefix = is_learn_page ? 'Learn: ' : '' return prefix + (category || 'Miscellaneous') end diff --git a/lib/docs/scrapers/react.rb b/lib/docs/scrapers/react.rb index a24798da..a4f0e0fe 100644 --- a/lib/docs/scrapers/react.rb +++ b/lib/docs/scrapers/react.rb @@ -1,6 +1,5 @@ module Docs class React < UrlScraper - include MultipleBaseUrls self.name = 'React' self.type = 'simple' @@ -11,15 +10,13 @@ module Docs version do self.release = '18.3.1' - host = 'https://react.dev' - self.base_urls = [ - "#{host}/reference", - "#{host}/learn", - ] - self.initial_paths = %w(/react) + self.base_url = 'https://react.dev' + self.initial_paths = %w(/reference/react /learn) html_filters.push 'react/entries_react_dev', 'react/clean_html_react_dev' + options[:only_patterns] = [/\A\/learn/, /\A\/reference/] + options[:attribution] = <<-HTML © 2013–present Facebook Inc.
Licensed under the Creative Commons Attribution 4.0 International Public License.