Browse Source

Add React Router documentation (6.2.1)

Simon Legner 3 years ago
parent
commit
c12b8e4797

+ 4 - 0
assets/javascripts/news.json

@@ -1,4 +1,8 @@
 [
+  [
+    "2021-01-12",
+    "New documentation: <a href=\"/react_router/\">React Router</a>"
+  ],
   [
     "2022-01-09",
     "New documentation: <a href=\"/deno/\">Deno</a>"

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -732,6 +732,11 @@ credits = [
     '2014-present Stephen J. Collings, Matthew Honnibal, Pieter Vanderwerff',
     'MIT',
     'https://raw.githubusercontent.com/react-bootstrap/react-bootstrap/master/LICENSE'
+  ], [
+    'React Router',
+    'React Training 2015-2019<br>Remix Software 2020-2021',
+    'MIT',
+    'https://raw.githubusercontent.com/remix-run/react-router/main/LICENSE.md'
   ], [
     'ReactiveX',
     'ReactiveX contributors',

+ 14 - 0
lib/docs/filters/react_router/clean_html.rb

@@ -0,0 +1,14 @@
+module Docs
+  class ReactRouter
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.md-prose')
+        css('pre').each do |node|
+          node.content = node.css('.codeblock-line').map(&:content).join("")
+          node['data-language'] = 'javascript'
+        end
+        doc
+      end
+    end
+  end
+end

+ 13 - 0
lib/docs/filters/react_router/entries.rb

@@ -0,0 +1,13 @@
+module Docs
+  class ReactRouter
+    class EntriesFilter < Docs::EntriesFilter
+      def additional_entries
+        entries = []
+        css('h2[id], h3[id]').each do |node|
+          entries << [node.content, node['id'], 'API Reference']
+        end
+        entries
+      end
+    end
+  end
+end

+ 26 - 0
lib/docs/scrapers/react_router.rb

@@ -0,0 +1,26 @@
+module Docs
+  class ReactRouter < UrlScraper
+    self.name = 'React Router'
+    self.slug = 'react_router'
+    self.type = 'simple'
+    self.release = '6.2.1'
+    self.base_url = 'https://reactrouterdotcom.fly.dev/docs/en/v6/api'
+
+    self.links = {
+      home: 'https://reactrouterdotcom.fly.dev/',
+      code: 'https://github.com/remix-run/react-router'
+    }
+
+    html_filters.push 'react_router/entries', 'react_router/clean_html', 'title'
+
+    options[:attribution] = <<-HTML
+      &copy; React Training 2015-2019<br>
+      &copy; Remix Software 2020-2021<br>
+      Licensed under the MIT License (MIT).
+    HTML
+
+    def get_latest_version(opts)
+      get_npm_version('react-router', opts)
+    end
+  end
+end

BIN
public/icons/docs/react_router/16.png


BIN
public/icons/docs/react_router/16@2x.png


+ 1 - 0
public/icons/docs/react_router/SOURCE

@@ -0,0 +1 @@
+https://reactrouterdotcom.fly.dev/favicon.ico