CloudCannon / pagefind

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

I created a vite adapter for pagefind! #549

Closed Hugos68 closed 5 months ago

Hugos68 commented 5 months ago

Hey there, I created a vite plugin for pagefind: https://github.com/Hugos68/vite-plugin-pagefind This will help people that are using: Svelte, Vue, Qwik, Solid or any other Vite based project. Wanted to share it but this honestly should probably be a package pagefind provides in the future, it does really make your life a lot easier.

This also solves #327 and partially solves #539.

wentallout commented 5 months ago

I tried it on my SvelteKit project. The search UI does show up and I can type in it. Only problem is that the url it navigates user to is wrong (404).

What I expect: http://localhost:3000/blog/perception-of-feedback-timing What it produced: http://localhost:3000/pagefind/blog/perception-of-feedback-timing.html

my config

const pagefindConfig = {
    publicDir: 'static',
    buildDir: 'build'
};
Hugos68 commented 5 months ago

Thanks for the feedback, I haven't used it with the UI, I will try and do the same as you did, there are still a few bugs with the plugin so I suggest you wait before using it, sorry for the inconvenience!

Hugos68 commented 5 months ago

@wentallout I just tested pagefind locally and it all works correctly: image The preview URL does add .html which you have to remove since sveltekit handles routes a bit differently but that can be easily done by adding:

.replace('.html', '');

What version of the plugin are you running? I just pushed a update that fixed a pathing issue, I suspect you were victim of it, also, if you have any further questions please open up an issue on the vite-plugin-pagefind repo as this isn't so much related to pagefind anymore.

bglw commented 5 months ago

Awesome @Hugos68 ! ❤️

I'll move this to a discussion so we can keep it alive, and I'll get this onto the website's resources page 🔜 !