fix(redirect): Stop failing on redirect pages
Fixes #60. Using `redirect_from` from the `jekyll-redirect-from` plugin was throwing errors. Such redirect files are now correctly excluded from indexing.
This commit is contained in:
parent
81327d8fad
commit
fc7847e842
@ -90,7 +90,15 @@ module Jekyll
|
||||
# an HTML meta refresh. We need to exclude those files from indexing.
|
||||
# https://github.com/jekyll/jekyll-redirect-from
|
||||
def self.redirect?(file)
|
||||
file.respond_to?(:name) && file.name == 'redirect.html'
|
||||
# When using redirect_from, jekyll-redirect-from creates a page named
|
||||
# `redirect.html`
|
||||
return true if file.respond_to?(:name) && file.name == 'redirect.html'
|
||||
# When using redirect_to, it sets the layout to `redirect`
|
||||
if file.respond_to?(:data) && file.data['layout'] == 'redirect'
|
||||
return true
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
# Public: Check if the file has one of the allowed extensions
|
||||
@ -305,6 +313,7 @@ module Jekyll
|
||||
selector = Configurator.algolia('nodes_to_index')
|
||||
first_node = Nokogiri::HTML(html).css(selector).first
|
||||
return nil if first_node.nil?
|
||||
|
||||
first_node.to_s
|
||||
end
|
||||
|
||||
|
||||
@ -200,6 +200,11 @@ describe(Jekyll::Algolia::FileBrowser) do
|
||||
let(:file) { double('File', name: 'redirect.html') }
|
||||
it { should eq true }
|
||||
end
|
||||
|
||||
describe 'file with a redirect layout' do
|
||||
let(:file) { double('File', data: { 'layout' => 'redirect' }) }
|
||||
it { should eq true }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.allowed_extension?' do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user