1
0
Fork 0

fix redirects

This commit is contained in:
Maxime 2018-02-07 12:05:46 +01:00
parent f905ff07fd
commit 02a2a7d7d4
2 changed files with 12 additions and 8 deletions

View file

@ -53,7 +53,6 @@ configure :server do
#activate :livereload
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
redirects.push({from: '/index.html' , to: '/docsearch'})
end
# Build-specific configuration
@ -73,13 +72,8 @@ end
ready do
no_redirect = ENV['NO_REDIRECTS'] && (ENV['NO_REDIRECTS'] == 'true')
is_travis_pr_build = ENV['TRAVIS_PULL_REQUEST'] && (ENV['TRAVIS_PULL_REQUEST'] != 'false')
if not no_redirect and not is_travis_pr_build
redirects.each do |r|
redirect r[:from][1..-1], to: r[:to]
end
redirects.each do |r|
proxy r[:from][1..-1], 'templates/redirect.html', locals: {url: r[:to]}, ignore: true, layout: nil
end
proxy '/_redirects', 'templates/redirects', locals: {redirects: redirects}, ignore: true

View file

@ -0,0 +1,10 @@
<html>
<head>
<base href="<%= app.config[:stage] == 'production' ? 'https://community.algolia.com/docsearch/': '/' %>">
<link rel=canonical href="<%= url %>"/>
<meta http-equiv=refresh content="0; url=<%= url %>"/>
<meta name=robots content="noindex,follow"/>
<meta http-equiv=cache-control content=no-cache />
</head>
<body> </body>
</html>