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

Correctly load the index.json for docs with one language #2

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

zoglo
Copy link
Contributor

@zoglo zoglo commented Feb 22, 2024

This fixes an issue with the search not working for two docs due to index.json not being resolved correctly.

Seaching within the documentation of Notification Center Pro works due to having de and en:

The search for Notification Center and Changelanguage does not work because the documentation only exists in english right now:

Copy link
Member

@Toflar Toflar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking on this! ❤️
We've discussed with @aschempp and we actually don't want to remove the /en/ prefix because maybe at some point someone contributes another language and then all the existing links would be broken which does not make a lot of sense to us.

@zoglo
Copy link
Contributor Author

zoglo commented Feb 23, 2024

@Toflar

If that's the case, we should just make use of the search and fix it here:

{{ if .Site.IsMultiLingual }}
var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
{{ else }}
var baseurl = "{{.Site.BaseURL}}";
{{ end }}

Just using:

var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";

would work.

@zoglo zoglo marked this pull request as draft February 23, 2024 09:08
@zoglo zoglo changed the title Dissolve the correct index.json Correctly load the index.json for docs with one language Feb 23, 2024
@zoglo
Copy link
Contributor Author

zoglo commented Feb 23, 2024

Changed it so it only affects the search

More information here:
https://discourse.gohugo.io/t/error-getting-lunr-index-file-when-site-is-open-from-disc/16473/5

They never fixed it but in your case since you never want to remove the language flag, this should always work.
I'm too lazy to open an account and throw in my solution after 5 years.

@zoglo zoglo marked this pull request as ready for review February 23, 2024 13:55
@zoglo zoglo requested a review from Toflar February 23, 2024 13:55
@Toflar Toflar merged commit 9598218 into terminal42:main Feb 23, 2024
@Toflar
Copy link
Member

Toflar commented Feb 23, 2024

Thank you so much!! ❤️

@zoglo zoglo deleted the bugfix/default-language-index branch February 23, 2024 15:34
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

Successfully merging this pull request may close these issues.

2 participants