freerange / site

Go Free Range website
http://gofreerange.com
7 stars 1 forks source link

Consider adding site search #430

Open floehopper opened 2 months ago

floehopper commented 2 months ago

@threedaymonk & @tomstuart have both used https://pagefind.app/ on their personal sites, so that might be worth a try.

tomstuart commented 2 months ago

In case it helps, I added a little bit of processResult JavaScript to remove the .html from the end of the URLs in Pagefind’s search results, since I don’t ordinarily use that when I link to pages (i.e. I have permalink: :title in my Jekyll config):

<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/pagefind/pagefind-ui.js"></script>
<div id="search"></div>
<script>
  window.addEventListener('DOMContentLoaded', function () {
    new PagefindUI({
      element: '#search',
      processResult: function (result) {
        result.url = result.url.replace(/\.html$/, '');
        return result;
      }
    });
  });
</script>

Good luck!

floehopper commented 2 months ago

Thanks, @tom!