CloudCannon / pagefind

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

Implement local development mode #14

Open bglw opened 2 years ago

bglw commented 2 years ago

When developing locally, Pagefind could watch and host a directory, so that a new SSG build would get picked up and indexed automatically.

bglw commented 2 years ago

Partially implemented — Pagefind now supports --serve but does not yet implement --watch

psaikido commented 2 years ago

For me, running pagefind against my hugo site on my dev server should result in me being able to use it on that server. The ui js and css lives at _pagefind/pagefind/ which is in the public dir. Fine for live but not when running 'hugo server'. This cannot then be tested and makes the project fall at the starting line.

psaikido commented 2 years ago

If it's super simple to set up on a development machine and I'm just too tired to figure it out, maybe there should be instructions on the 'getting started' pages.

bglw commented 2 years ago

Hello @psaikido 👋

With the standard steps and Hugo, Pagefind will only be seen on Pagefind's dev server, as Hugo serves from its own memory and not from the public directory. When running Pagefind with --serve you'll get a Pagefind dev server to test the search with.

There is a way locally to get Pagefind visible through your Hugo dev server, but it requires a couple of extra steps. There's a good guide here from Bryce & Régis: https://www.brycewray.com/posts/2022/07/pagefind-quite-find-site-search/#update-2021-07-31

psaikido commented 2 years ago

Champion! Those extra steps have helped and it's working now. The standard steps with pagefinder and hugo are for a live server since it outputs the index to 'public'. Hugo running locally gets its sources from 'static'. The help pages seem to assume that folks will go directly to live with no intermediate steps whatsoever. This seems unlikely and I'd suggest modifying the instructions at https://pagefind.app/docs/ especially where it says "bask in how easy that was to integrate" ;)