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

search: don't break JS in multilang setup if search is disabled #140

Closed
lindeMAX opened this issue Nov 4, 2021 · 1 comment
Closed

search: don't break JS in multilang setup if search is disabled #140

lindeMAX opened this issue Nov 4, 2021 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@lindeMAX
Copy link

lindeMAX commented Nov 4, 2021

Hi.
I recognized, that the language switching is not working if one disables the search bar in the config.toml.

[params]
disableSearch = true

If so, you will get an error trying to change the language: Uncaught ReferenceError: baseUri is not defined.
Beacuse of this part in the html-files:

<select id="select-language" onchange="location = baseUri + this.value;">
   <option id="en" value="/" selected>English</option>
   <option id="de" value="/de/">Deutsch</option>
</select>

This is because of a script in search.html (https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/search.html), that should rather be somewehere else.

var index_url={{ "index.json" | relLangURL }};
var root_url="/";
var baseUri=root_url.replace(/\/$/, '');

I managed to work around this issue by putting the script in to the cusom-footer.html (https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/custom-footer.html)

<script>
   var index_url={{ "index.json" | relLangURL }};
   var root_url="/";
   var baseUri=root_url.replace(/\/$/, '');
</script>
@McShelby McShelby self-assigned this Nov 4, 2021
@McShelby McShelby added the bug Something isn't working label Nov 4, 2021
@McShelby McShelby added this to the 2.8.1 milestone Nov 4, 2021
@McShelby
Copy link
Owner

McShelby commented Nov 4, 2021

Thanks for reporting. This is definatly a bug. Will be fixed with the next version.

@McShelby McShelby changed the title Multilanguage with Search disabled search: don't break JS in multilang setup if search is disabled Nov 4, 2021
@McShelby McShelby closed this as completed Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants