| @@ -0,0 +1,68 @@ |
| | 1 | module Docs |
| | 2 | class Vuex |
| | 3 | class EntriesFilter < Docs::EntriesFilter |
| | 4 | def get_name |
| | 5 | name = at_css('h1').content |
| | 6 | |
| | 7 | name.remove! '# ' |
| | 8 | |
| | 9 | # Add index on guides |
| | 10 | unless subpath.start_with?('api') |
| | 11 | sidebarLink = at_css('.sidebar-link.active') |
| | 12 | allLinks = css('.sidebar-link:not([href="/"]):not([href="../index"])') |
| | 13 | |
| | 14 | index = allLinks.index(sidebarLink) |
| | 15 | |
| | 16 | name.prepend "#{index + 1}. " if index |
| | 17 | end |
| | 18 | |
| | 19 | name |
| | 20 | end |
| | 21 | |
| | 22 | def get_type |
| | 23 | 'Guide' |
| | 24 | end |
| | 25 | |
| | 26 | def include_default_entry? |
| | 27 | name != 'API Reference' |
| | 28 | end |
| | 29 | |
| | 30 | def additional_entries |
| | 31 | return [] unless subpath.start_with?('api') |
| | 32 | |
| | 33 | entries = [ |
| | 34 | ['Component Binding Helpers', 'component-binding-helpers', 'API Reference'], |
| | 35 | ['Store', 'vuex-store', 'API Reference'], |
| | 36 | ] |
| | 37 | |
| | 38 | css('h3').each do |node| |
| | 39 | entryName = node.content.strip |
| | 40 | |
| | 41 | # Get the previous h2 title |
| | 42 | title = node |
| | 43 | title = title.previous_element until title.name == 'h2' |
| | 44 | title = title.content.strip |
| | 45 | title.remove! '# ' |
| | 46 | |
| | 47 | entryName.remove! '# ' |
| | 48 | |
| | 49 | unless entryName.start_with?('router.') |
| | 50 | if title == "Vuex.Store Constructor Options" |
| | 51 | entryName = "StoreOptions.#{entryName}" |
| | 52 | elsif title == "Vuex.Store Instance Properties" |
| | 53 | entryName = "Vuex.Store.#{entryName}" |
| | 54 | elsif title == "Vuex.Store Instance Methods" |
| | 55 | entryName = "Vuex.Store.#{entryName}()" |
| | 56 | elsif title == "Component Binding Helpers" |
| | 57 | entryName = "#{entryName}()" |
| | 58 | end |
| | 59 | end |
| | 60 | |
| | 61 | entries << [entryName, node['id'], 'API Reference'] |
| | 62 | end |
| | 63 | |
| | 64 | entries |
| | 65 | end |
| | 66 | end |
| | 67 | end |
| | 68 | end |