google / docsy

A set of Hugo doc templates for launching open source content.
https://docsy.dev
Apache License 2.0
2.55k stars 888 forks source link

Lunr search with support for other languages than English #553

Open LarsAlmgren opened 3 years ago

LarsAlmgren commented 3 years ago

I've created a Hugo site with Docsy in Swedish and would like to change Lunr search language from English to Swedish. Is it possible to configure somehow? I've been looking around but not found anyone describing how one could do it.

Lunr support more languages than English and I've also found a Swedish stemmer

LisaFC commented 3 years ago

@tekezo, do you know how users could configure this? Thanks!

tekezo commented 3 years ago

There is no configuration item at the moment, and I think you can get it to work by modifying the following part locally.

https://github.com/google/docsy/blob/0b5c79c76173088226a1951636d0f29d77165808/assets/js/offline-search.js#L47 https://github.com/google/docsy/blob/0b5c79c76173088226a1951636d0f29d77165808/layouts/partials/head.html#L34

It would be preferable if lunr-languages were automatically adapted from the content languages, so I would like to make such a modification in the future.

theletterf commented 3 years ago

Hmm. I didn't think of this when I added offline search in https://github.com/google/docsy/pull/142.

@tekezo Perhaps one way to deal with this could be to enable multilanguage support?

https://lunrjs.com/guides/language_support.html