Pagefind: the New Rust-Based Search Tool (with Astro)

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ก.พ. 2025

ความคิดเห็น • 36

  • @CookingForAlba-qh8nq
    @CookingForAlba-qh8nq ปีที่แล้ว +5

    Quickly becoming the de-facto source for everything Astro.

  • @jokerrb6040
    @jokerrb6040 ปีที่แล้ว +3

    This is gold for documentation websites!!

  • @jitxhere
    @jitxhere ปีที่แล้ว +1

    Wow this is awesome. Gonna try this. Thanks for the easy to follow tutorial

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      You’re welcome 😊 glad it was a help!

  • @charliecoppinger
    @charliecoppinger ปีที่แล้ว

    Liam Bigelow is a king 👑 great video, subscribed!

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว +1

      Liam is 🔥 thanks for the sub!

  • @eyallampel
    @eyallampel ปีที่แล้ว +2

    I'm encountering a wierd issue on my website. I have implemented a search element, which functions correctly as demonstrated in the video. However, I'm facing a problem where the search element disappears after navigating through the site. The only way to get the search element to reappear is by refreshing the main page. No idea why .

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Are you using page transitions?

    • @eyallampel
      @eyallampel ปีที่แล้ว

      @@CodinginPublic
      Thank you for pointing out the potential issue with page transitions. Your insight was spot on! I am indeed using the Astro framework, and it turns out that the ViewTransitions was to blame for the disappearing search element on my website.
      Following your hint, I experimented by removing the ViewTransitions, and the search element stopped disappearing. However, I am keen on utilizing ViewTransitions for my site. If you have any further advice on how I might be able to use ViewTransitions without causing the search element to disappear, it would be greatly appreciated.

    • @nhendriks
      @nhendriks ปีที่แล้ว

      @@CodinginPublic same thing and yes using view transitions.
      Solved it this way. seems to work, not sure if it is how it should be fixed though.
      ```js
      const searchUI = {
      init: function () {
      new PagefindUI({element: "#search", showSubResults: true});
      }
      };
      // Runs on initial navigation
      searchUI.init();
      // Runs on view transitions navigation
      document.addEventListener('astro:after-swap', searchUI.init);
      ```

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      @@nhendriks nice work! I’m wondering if adding transition:persist to the div you place on the page would be enough? Haven’t tested it though.

    • @morispasic
      @morispasic ปีที่แล้ว +1

      Try this instead (the min-height styling is to prevent it from jumping on screen every time it loads):
      function initSearch() {
      // @ts-ignore
      new PagefindUI({ element: "#search", showSubResults: true });
      }

      document.addEventListener('astro:page-load', initSearch);

  • @patrickchan2503
    @patrickchan2503 2 วันที่ผ่านมา

    thanks, not so scary tech, they don't have documentation on hugo but I'll give this a go

  • @marcogomesrd
    @marcogomesrd ปีที่แล้ว

    but how can I remove the trailingSlash when doing a search? when I click on a link from the search is giving me a not found because I had not url ending with "/"
    I tried using data-pagefind-meta="url[href] on my anchor tag but ditn't work.. not sure how to solve this

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Hmm. Do you have the trailing slash property set in your Astro config?

  • @robertostringa9254
    @robertostringa9254 8 หลายเดือนก่อน

    Great, and something like this for a headless site ... like Wordpress headless posts ?

  • @jjaimealeman
    @jjaimealeman ปีที่แล้ว

    Another Golden Post ⭐ Can wake this try this

  • @unity_12
    @unity_12 ปีที่แล้ว

    Please say! Whats is plugin show you errors in code ts?

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Hmm. I think it’s the Astro extension? Mind sending me a timestamp to an example?

    • @unity_12
      @unity_12 ปีที่แล้ว

      Already solved the problem! It's always like this with me)@@CodinginPublic

  • @zacharystout8573
    @zacharystout8573 ปีที่แล้ว

    I can't seem to get this to work. I'm deploying with vercel and each time I get the same error:
    Error: Pagefind wasn't able to build an index.
    Most likely, the directory passed to Pagefind was empty or did not contain any html files.
     ELIFECYCLE  Command failed with exit code 1.
    Error: Command "pnpm run build" exited with 1
    Any thoughts?

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว

      Hmm…I'm not sure off hand. It may be how you’re referencing the pagefind rendered directory?

  • @MrIberius13
    @MrIberius13 ปีที่แล้ว

    Hi chris, I've started using astro thanks to your videos, but i'm struggling with one topic, dynamic routes, for no reason i get a
    Promise { }
    undefined
    node:internal/deps/undici/undici:6630
    throw new TypeError("Body is unusable");
    ^
    TypeError: Body is unusable
    but searching the api in any other framework/Library it returns just fine.
    I know its a bit of an ask but is there a way you know how i could get some help?

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว +1

      Sounds like you’re forgetting to await? Are you able to compare your code with an example and see if they have an await in the statement?

    • @MrIberius13
      @MrIberius13 ปีที่แล้ว

      @@CodinginPublic and for some context, it returns the data, in the terminal from the fetch res.json() but I think when I return it it says unusable data at position 1. And then when I log the data in the slug, it errors

  • @yunhanhuang9304
    @yunhanhuang9304 ปีที่แล้ว

    Love your video😁

  • @funkologie
    @funkologie ปีที่แล้ว

    Beautiful 🎉

  • @MrDermases
    @MrDermases ปีที่แล้ว

    That's interesting. So, if I'm understanding correctly, this is specifically designed for SSG? Does this imply that if I wanted to use pagefind with Next.js, all the sites I want searchable would need to be statically generated? How does Incremental Static Regeneration (ISR) play into this?
    I know your mostly working with Astro, but pagefind looks really cool, and I am interested to see where else i could use it.

    • @CodinginPublic
      @CodinginPublic  ปีที่แล้ว +1

      They claim “any framework,” but I’m assuming you’d need to statically generate the pages you want indexed? Not sure how ISR plays into that? Sorry! Let me know if you figure out!

  • @OnlyJavascript
    @OnlyJavascript ปีที่แล้ว +1

    first