CloudCannon / pagefind

Static low-bandwidth search at scale
https://pagefind.app
MIT License
3.22k stars 97 forks source link

Changing the text "clear" of the clearing button #577

Closed evanescente-ondine closed 3 months ago

evanescente-ondine commented 3 months ago

Hi, I'm a bit bugged by the "Clear" content of the button element, I wish I could get a X instead, or an arbitrary nice character, or an svg. What do I need to write with "new PagefindUI(" to correct that ? I don't know javascript.

Thanks

nhoizey commented 3 months ago

@evanescente-ondine you can change the labels like this:

window.addEventListener('DOMContentLoaded', (event) => {
    new PagefindUI(
      {
        element: "#search",
        translations: {
          clear_search: "X",
        }
      });
  });

Other translatable strings are listed here: https://github.com/CloudCannon/pagefind/blob/main/pagefind_ui/translations/en.json

I don't think you can put an image there.

evanescente-ondine commented 3 months ago

ok, I'm starting to understand the pattern now. Much thanks, what a great app.