Unified · Split
| @@ -1,8 +1,19 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Click |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | − | |
| 5 | − def initialize(*) | |
| 4 | + TYPE_BY_SLUG = {} | |
| 5 | + | |
| 6 | + def call | |
| 7 | + if root_page? | |
| 8 | + css('section').each do |node| | |
| 9 | + next if ['documentation', 'api-reference'].include?(node['id']) | |
| 10 | + type = node.at_css('h2').content.strip | |
| 11 | + node.css('li > a').each do |toclink| | |
| 12 | + slug = toclink['href'].split('/')[-2] | |
| 13 | + TYPE_BY_SLUG[slug] = type | |
| 14 | + end | |
| 15 | + end | |
| 16 | + end | |
| 6 | 17 | super |
| 7 | 18 | end |
| 8 | 19 | |
| @@ -11,15 +22,15 @@ module Docs · 2 unmodified lines | ||
| 11 | 22 | end |
| 12 | 23 | |
| 13 | 24 | def get_type |
| 14 | − return at_css('h1').content.strip | |
| 25 | + TYPE_BY_SLUG[slug.split('/').first] || at_css('h1').content.strip | |
| 15 | 26 | end |
| 16 | 27 | |
| 17 | 28 | def include_default_entry? |
| 18 | − false | |
| 29 | + TYPE_BY_SLUG.include?(slug.split('/').first) | |
| 19 | 30 | end |
| 20 | 31 | |
| 21 | 32 | def additional_entries |
| 22 | − return [] if root_page? | |
| 33 | + return [] if root_page? || TYPE_BY_SLUG.include?(slug.split('/').first) | |
| 23 | 34 | |
| 24 | 35 | if slug == 'api/' |
| 25 | 36 | entries = [] |