Skip to content

Commit 2d6c1be

Browse files
committed
Add Vue Router reference
1 parent 6ecd9d8 commit 2d6c1be

File tree

7 files changed

+121
-0
lines changed

7 files changed

+121
-0
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ credits = [
680680
'2013-2018 Evan You, Vue.js contributors',
681681
'MIT',
682682
'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
683+
], [
684+
'Vue Router',
685+
'2013-2018 Evan You, Vue.js contributors',
686+
'MIT',
687+
'https://github.com/vuejs/vue-router/blob/dev/LICENSE'
683688
], [
684689
'Vulkan',
685690
'2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Docs
2+
class VueRouter
3+
class CleanHtmlFilter < Filter
4+
def call
5+
@doc = at_css('.content')
6+
7+
# Remove unneeded elements
8+
css('.bit-sponsor, .header-anchor').remove
9+
10+
doc
11+
end
12+
end
13+
end
14+
end
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module Docs
2+
class VueRouter
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
name = at_css('h1').content
6+
7+
name.remove! '# '
8+
9+
name
10+
end
11+
12+
def get_type
13+
return 'Other Guides' if subpath.start_with?('guide/advanced')
14+
return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation')
15+
16+
'API Reference'
17+
end
18+
19+
def include_default_entry?
20+
name != 'API Reference'
21+
end
22+
23+
def additional_entries
24+
return [] unless subpath.start_with?('api')
25+
26+
entries = [
27+
['<router-link>', 'router-link', 'API Reference'],
28+
['<router-view>', 'router-view', 'API Reference'],
29+
['$route', 'the-route-object', 'API Reference'],
30+
['Component Injections', 'component-injections', 'API Reference']
31+
]
32+
33+
css('h3').each do |node|
34+
entryName = node.content.strip
35+
36+
# Get the previous h2 title
37+
title = node
38+
title = title.previous_element until title.name == 'h2'
39+
title = title.content.strip
40+
title.remove! '# '
41+
42+
entryName.remove! '# '
43+
44+
unless entryName.start_with?('router.')
45+
if title == "Router Construction Options"
46+
entryName = "RouterOptions.#{entryName}"
47+
elsif title == "<router-view> Props"
48+
entryName = "<router-view> `#{entryName}` prop"
49+
elsif title == "<router-link> Props"
50+
entryName = "<router-link> `#{entryName}` prop"
51+
else
52+
entryName = "> #{entryName} (in: #{title})"
53+
end
54+
end
55+
56+
unless title == "Component Injections" || node['id'] == 'applying-active-class-to-outer-element' || node['id'] == 'route-object-properties'
57+
entries << [entryName, node['id'], 'API Reference']
58+
end
59+
end
60+
61+
css('#route-object-properties + ul > li > p:first-child > strong').each do |node|
62+
entryName = node.content.strip
63+
id = "route-object-#{entryName.remove('$route.')}"
64+
65+
node['id'] = id
66+
entries << [entryName, node['id'], 'API Reference']
67+
end
68+
69+
entries
70+
end
71+
end
72+
end
73+
end

lib/docs/scrapers/vue_router.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module Docs
2+
class VueRouter < UrlScraper
3+
self.slug = 'vue_router'
4+
self.name = 'Vue Router'
5+
self.type = 'simple'
6+
7+
self.links = {
8+
home: 'https://router.vuejs.org',
9+
code: 'https://github.com/vuejs/vue-router'
10+
}
11+
12+
html_filters.push 'vue_router/entries', 'vue_router/clean_html'
13+
14+
self.release = '3.0.1'
15+
self.base_url = 'https://router.vuejs.org/'
16+
17+
options[:skip_patterns] = [
18+
# Other languages
19+
/^(zh|ja|ru|kr)\//,
20+
]
21+
22+
options[:attribution] = <<-HTML
23+
&copy; 2013&ndash;2018 Evan You, Vue.js contributors<br>
24+
Licensed under the MIT License.
25+
HTML
26+
end
27+
end

public/icons/docs/vue_router/16.png

1.18 KB
Loading
1.97 KB
Loading

public/icons/docs/vue_router/SOURCE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
http://vuejs.org/
2+
(Edited from the original logo to distinguish Vue Router from Vue)

0 commit comments

Comments
 (0)