CloudCannon / pagefind

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

Pagefind UI: Allow for custom templates to render search results #170

Open justsilencia opened 1 year ago

justsilencia commented 1 year ago

When the search results are shown along with the excerpt, it would be nice if the excerpt were also wrapped within the anchor tag. On mobile especially, it would give a much larger clickable area.

I've been able to make most customizations happen with CSS or JS mods, but I'm not sure if there's a workaround for this that's bug free.

bglw commented 1 year ago

Since this is getting into personal preference it's something that I would prefer to expose via some customization. Personally I don't like wrapping heading + summary in anchor tags, and for the Pagefind UI I deferred to Google's behaviour on desktop and mobile of leaving the excerpt text selectable.

I have seen other search implementations allow you to provide custom HTML templates for search results that would allow you to take things in any direction, so that it likely the solution I would reach for here.

Recently I have been tossing up providing a library of UI widgets that can be used, and this feature would be a good fit for a alternative Pagefind UI with more granularity, which might also tackle #53 and #54 while keeping the existing Pagefind UI as the default "starter" with the lowest configuration lift.

justsilencia commented 1 year ago

Yeah I was actually considering forking and taking a look at making this more customizable. I like to make the search a major feature of the site, so being able to provide a custom template would be ideal. Unfortunately I have quite a few projects on my plate so for the most part I'll have to wait and see what goodies you decide to bless us with :)

bglw commented 1 year ago

Hi @justsilencia — the latest release v0.11.0 includes an early look at the new Modular UI, which includes this feature. Have a wee skim of that and let me know how that looks!

bglw commented 1 year ago

Removing this from the 1.0 milestone as the Modular UI is now targeting a later release (see https://github.com/CloudCannon/pagefind/pull/382)