feat: Enable removing from navigation tree from pattern

This commit is contained in:
imtodor 2018-09-20 12:06:43 +03:00
Родитель 783c85a1ce
Коммит 9351e3ee6f
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -3,6 +3,7 @@ module Jekyll
class NavigationGenerator < Generator
def initialize(config)
@navigation = Hash[(config['navigation'] || {}).map { |key, value| [/^#{key.gsub('*', '.*?')}$/, value] }]
@exclude_navigation = (config['exclude_navigation'] || {}).map { |item| /^#{item.gsub('*', '.*?')}$/ }
end
def categories(site)
@ -22,7 +23,7 @@ module Jekyll
url = page.url.sub('/', '')
next if url.include? "knowledge-base/"
next if @exclude_navigation.any? { |regex| regex.match(url) }
segments = url.split('/')
@ -30,7 +31,6 @@ module Jekyll
item = node.find { |n| n['path'] == segment }
unless item
item = { 'path' => segment }
if index == segments.size - 1