Skip to content

Commit

Permalink
fix: Pagefind init issue
Browse files Browse the repository at this point in the history
  • Loading branch information
riceball-tw committed Apr 13, 2024
1 parent d12c9a1 commit e599c15
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const heroBadge = {

<script>
function initPagefind() {
if (!document.getElementById('pagefind-search')) return
const pagefindElement = document.getElementById('pagefind-search');
if (pagefindElement?.dataset.initialized) return;
pagefindElement?.setAttribute("data-initialized", 'true')
// External Code, Skip lint
// https://pagefind.app/docs/ui-usage/
// @ts-ignore-next-line
Expand All @@ -45,10 +47,12 @@ const heroBadge = {
sort: { date: "desc" },
});
}

document.addEventListener('astro:page-load', () => {
initPagefind();
});

initPagefind()
</script>

<BlogBase>
Expand Down

0 comments on commit e599c15

Please sign in to comment.