Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support relative links with search_index_path #5

Open
rtack opened this issue Nov 25, 2015 · 2 comments
Open

Support relative links with search_index_path #5

rtack opened this issue Nov 25, 2015 · 2 comments

Comments

@rtack
Copy link
Contributor

rtack commented Nov 25, 2015

Using search_index_path I always got the absolute path back but for hosting on github a relative path is needed.

I wrote my own helper which uses link_to to get the relative path.

def link_to_search_index
  absolute_link_to_index = '/' + extensions[:search].options[:index_path]
  dom = Nokogiri.HTML(link_to '', absolute_link_to_index)
  node = dom.at_xpath '//a'
  node[:href]
end
@matiasgarciaisaia
Copy link
Member

Yeah - this is definitely an issue.

The real problem is, I think, that you can have the search box at different path levels (ie, at our site you can search from http://manas.com.ar/, http://manas.com.ar/staff, or http://manas.com.ar/staff/mgarcia). In those cases, if you want to use a relative URL you have to use them differently - or add any way to the page for declaring how many nesting levels to go back.

It's definitely doable, but I'm not that sure your helper works for all the cases. I'll give it a try - and start implementing that if works at least for a nice percentage of the cases. But I think there's more than that for this issue.

Thanks for the feedback! :)

@spalladino spalladino changed the title support relative links with search_index_path Support relative links with search_index_path Apr 20, 2016
@matiasgarciaisaia
Copy link
Member

@rtack we've just released middleman-search v0.8.0, which includes #9

That should solve your issue. It doesn't use relative paths, but the absolute paths it uses honor the :http_prefix Middleman setting.

Can you confirm us this works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants