mirror of https://github.com/freeCodeCamp/devdocs
commit
74bf81fd72
@ -1,40 +1,28 @@
|
|||||||
module Docs
|
module Docs
|
||||||
class Babel
|
class Babel
|
||||||
class EntriesFilter < Docs::EntriesFilter
|
class EntriesFilter < Docs::EntriesFilter
|
||||||
|
|
||||||
|
ENTRIES = {
|
||||||
|
'Usage' => ['Options', 'Config Files', '@babel/cli', '@babel/polyfill',
|
||||||
|
'@babel/plugin-transform-runtime', '@babel/register'],
|
||||||
|
|
||||||
|
'Presets' => ['@babel/preset-env', '@babel/preset-flow', '@babel/preset-react', '@babel/preset-typescript'],
|
||||||
|
|
||||||
|
'Tooling' => ['@babel/parser', '@babel/core', '@babel/generator', '@babel/code-frame',
|
||||||
|
'@babel/helpers', '@babel/runtime', '@babel/template', '@babel/traverse', '@babel/types']
|
||||||
|
}
|
||||||
|
|
||||||
def get_name
|
def get_name
|
||||||
at_css('h1').content
|
at_css('h1').content
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_type
|
def get_type
|
||||||
if subpath.start_with?('plugins/preset')
|
ENTRIES.each do |key, value|
|
||||||
'Presets'
|
return key if value.include?(name)
|
||||||
elsif subpath.start_with?('plugins/transform')
|
return 'Other Plugins' if subpath.include?('babel-plugin')
|
||||||
'Transform Plugins'
|
|
||||||
elsif subpath.start_with?('plugins/minify')
|
|
||||||
'Minification'
|
|
||||||
elsif subpath.start_with?('plugins/syntax')
|
|
||||||
'Syntax Plugins'
|
|
||||||
elsif subpath.start_with?('plugins')
|
|
||||||
'Plugins'
|
|
||||||
elsif subpath.start_with?('usage/')
|
|
||||||
'Usage'
|
|
||||||
elsif subpath.start_with?('core-packages/')
|
|
||||||
'Core Packages'
|
|
||||||
else
|
|
||||||
'Miscellaneous'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def additional_entries
|
|
||||||
return [] unless slug.include?('api')
|
|
||||||
|
|
||||||
css('h2').each_with_object [] do |node, entries|
|
|
||||||
name = node.content.strip
|
|
||||||
next unless name.start_with?('babel.')
|
|
||||||
name.sub! %r{\(.*}, '()'
|
|
||||||
entries << [name, node['id']]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in new issue