mirror of https://github.com/freeCodeCamp/devdocs
parent
6ecd9d8cc2
commit
2d6c1be335
@ -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
|
@ -0,0 +1,73 @@
|
|||||||
|
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>', 'router-link', 'API Reference'],
|
||||||
|
['<router-view>', 'router-view', 'API Reference'],
|
||||||
|
['$route', 'the-route-object', 'API Reference'],
|
||||||
|
['Component Injections', 'component-injections', 'API Reference']
|
||||||
|
]
|
||||||
|
|
||||||
|
css('h3').each do |node|
|
||||||
|
entryName = node.content.strip
|
||||||
|
|
||||||
|
# Get the previous h2 title
|
||||||
|
title = node
|
||||||
|
title = title.previous_element until title.name == 'h2'
|
||||||
|
title = title.content.strip
|
||||||
|
title.remove! '# '
|
||||||
|
|
||||||
|
entryName.remove! '# '
|
||||||
|
|
||||||
|
unless entryName.start_with?('router.')
|
||||||
|
if title == "Router Construction Options"
|
||||||
|
entryName = "RouterOptions.#{entryName}"
|
||||||
|
elsif title == "<router-view> Props"
|
||||||
|
entryName = "<router-view> `#{entryName}` prop"
|
||||||
|
elsif title == "<router-link> Props"
|
||||||
|
entryName = "<router-link> `#{entryName}` prop"
|
||||||
|
else
|
||||||
|
entryName = "> #{entryName} (in: #{title})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless title == "Component Injections" || node['id'] == 'applying-active-class-to-outer-element' || node['id'] == 'route-object-properties'
|
||||||
|
entries << [entryName, node['id'], 'API Reference']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
css('#route-object-properties + ul > li > p:first-child > strong').each do |node|
|
||||||
|
entryName = node.content.strip
|
||||||
|
id = "route-object-#{entryName.remove('$route.')}"
|
||||||
|
|
||||||
|
node['id'] = id
|
||||||
|
entries << [entryName, node['id'], 'API Reference']
|
||||||
|
end
|
||||||
|
|
||||||
|
entries
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,27 @@
|
|||||||
|
module Docs
|
||||||
|
class VueRouter < UrlScraper
|
||||||
|
self.slug = 'vue_router'
|
||||||
|
self.name = 'Vue Router'
|
||||||
|
self.type = 'simple'
|
||||||
|
|
||||||
|
self.links = {
|
||||||
|
home: 'https://router.vuejs.org',
|
||||||
|
code: 'https://github.com/vuejs/vue-router'
|
||||||
|
}
|
||||||
|
|
||||||
|
html_filters.push 'vue_router/entries', 'vue_router/clean_html'
|
||||||
|
|
||||||
|
self.release = '3.0.1'
|
||||||
|
self.base_url = 'https://router.vuejs.org/'
|
||||||
|
|
||||||
|
options[:skip_patterns] = [
|
||||||
|
# Other languages
|
||||||
|
/^(zh|ja|ru|kr)\//,
|
||||||
|
]
|
||||||
|
|
||||||
|
options[:attribution] = <<-HTML
|
||||||
|
© 2013–2018 Evan You, Vue.js contributors<br>
|
||||||
|
Licensed under the MIT License.
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
end
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,2 @@
|
|||||||
|
http://vuejs.org/
|
||||||
|
(Edited from the original logo to distinguish Vue Router from Vue)
|
Loading…
Reference in new issue