diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 4a2a722c..67fade42 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -734,6 +734,11 @@ credits = [ '2013-2018 Evan You, Vue.js contributors', 'MIT', 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE' + ], [ + 'Vue Router', + '2013-present Evan You', + 'MIT', + 'https://raw.githubusercontent.com/vuejs/vue-router/dev/LICENSE' ], [ 'Vulkan', '2014-2017 Khronos Group Inc.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.', diff --git a/lib/docs/filters/vue_router/clean_html.rb b/lib/docs/filters/vue_router/clean_html.rb new file mode 100644 index 00000000..19c6e7ae --- /dev/null +++ b/lib/docs/filters/vue_router/clean_html.rb @@ -0,0 +1,14 @@ +module Docs + class VueRouter + class CleanHtmlFilter < Filter + def call + @doc = at_css('.content') + + # Remove unneeded elements + css('.bit-sponsor, .header-anchor').remove + + doc + end + end + end +end diff --git a/lib/docs/filters/vue_router/entries.rb b/lib/docs/filters/vue_router/entries.rb new file mode 100644 index 00000000..b38fed28 --- /dev/null +++ b/lib/docs/filters/vue_router/entries.rb @@ -0,0 +1,71 @@ +module Docs + class VueRouter + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('h1').content + name.remove! '# ' + name + end + + def get_type + return 'Other Guides' if subpath.start_with?('guide/advanced') + return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation') + 'API Reference' + end + + def include_default_entry? + name != 'API Reference' + end + + def additional_entries + return [] unless subpath.start_with?('api') + + entries = [ + ['', 'router-link', 'API Reference'], + ['', 'router-view', 'API Reference'], + ['$route', 'the-route-object', 'API Reference'], + ['Component Injections', 'component-injections', 'API Reference'] + ] + + css('h3').each do |node| + entry_name = node.content.strip + + # Get the previous h2 title + title = node + title = title.previous_element until title.name == 'h2' + title = title.content.strip + title.remove! '# ' + + entry_name.remove! '# ' + + case title + when 'Router Construction Options' + entry_name = "RouterOptions.#{entry_name}" + when ' Props' + entry_name = " `#{entry_name}` prop" + when ' Props' + entry_name = " `#{entry_name}` prop" + when 'Router Instance Methods' + entry_name = "#{entry_name}()" + end + + entry_name = entry_name.split(' API ')[0] if entry_name.start_with?('v-slot') + + unless title == "Component Injections" || node['id'] == 'route-object-properties' + entries << [entry_name, node['id'], 'API Reference'] + end + end + + css('#route-object-properties + ul > li > p:first-child > strong').each do |node| + entry_name = node.content.strip + id = "route-object-#{entry_name.remove('$route.')}" + + node['id'] = id + entries << [entry_name, node['id'], 'API Reference'] + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/vue_router.rb b/lib/docs/scrapers/vue_router.rb new file mode 100644 index 00000000..9f617944 --- /dev/null +++ b/lib/docs/scrapers/vue_router.rb @@ -0,0 +1,29 @@ +module Docs + class VueRouter < UrlScraper + self.name = 'Vue Router' + self.slug = 'vue_router' + self.type = 'simple' + self.release = '3.1.2' + self.base_url = 'https://router.vuejs.org/' + self.links = { + home: 'https://router.vuejs.org', + code: 'https://github.com/vuejs/vue-router' + } + + html_filters.push 'vue_router/entries', 'vue_router/clean_html' + + options[:skip_patterns] = [ + # Other languages + /^(zh|ja|ru|kr|fr)\//, + ] + + options[:attribution] = <<-HTML + © 2013–present Evan You
+ Licensed under the MIT License. + HTML + + def get_latest_version(opts) + get_latest_github_release('vuejs', 'vue-router', opts) + end + end +end diff --git a/public/icons/docs/vue_router/16.png b/public/icons/docs/vue_router/16.png new file mode 100644 index 00000000..153c58cd Binary files /dev/null and b/public/icons/docs/vue_router/16.png differ diff --git a/public/icons/docs/vue_router/16@2x.png b/public/icons/docs/vue_router/16@2x.png new file mode 100644 index 00000000..7a277fae Binary files /dev/null and b/public/icons/docs/vue_router/16@2x.png differ diff --git a/public/icons/docs/vue_router/SOURCE b/public/icons/docs/vue_router/SOURCE new file mode 100644 index 00000000..6999e8c5 --- /dev/null +++ b/public/icons/docs/vue_router/SOURCE @@ -0,0 +1 @@ +https://github.com/vuejs/vuejs.org/blob/master/assets/logo.ai