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
0 commit comments