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.
|
# an HTML meta refresh. We need to exclude those files from indexing.
|
||||||
# https://github.com/jekyll/jekyll-redirect-from
|
# https://github.com/jekyll/jekyll-redirect-from
|
||||||
def self.redirect?(file)
|
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
|
end
|
||||||
|
|
||||||
# Public: Check if the file has one of the allowed extensions
|
# Public: Check if the file has one of the allowed extensions
|
||||||
@ -305,6 +313,7 @@ module Jekyll
|
|||||||
selector = Configurator.algolia('nodes_to_index')
|
selector = Configurator.algolia('nodes_to_index')
|
||||||
first_node = Nokogiri::HTML(html).css(selector).first
|
first_node = Nokogiri::HTML(html).css(selector).first
|
||||||
return nil if first_node.nil?
|
return nil if first_node.nil?
|
||||||
|
|
||||||
first_node.to_s
|
first_node.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -200,6 +200,11 @@ describe(Jekyll::Algolia::FileBrowser) do
|
|||||||
let(:file) { double('File', name: 'redirect.html') }
|
let(:file) { double('File', name: 'redirect.html') }
|
||||||
it { should eq true }
|
it { should eq true }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'file with a redirect layout' do
|
||||||
|
let(:file) { double('File', data: { 'layout' => 'redirect' }) }
|
||||||
|
it { should eq true }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.allowed_extension?' do
|
describe '.allowed_extension?' do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user