diff --git a/src/components/ui/BackButton.astro b/src/components/ui/BackButton.astro index 0d9f41d..17ec908 100644 --- a/src/components/ui/BackButton.astro +++ b/src/components/ui/BackButton.astro @@ -62,12 +62,8 @@ import { themeConfig } from '@/config' adjustBackButtonPosition() - document.addEventListener('astro:page-load', () => { - adjustBackButtonPosition() - }) - document.addEventListener('DOMContentLoaded', () => { - adjustBackButtonPosition() - }) + // Use only astro:page-load as it fires on initial load and navigation + document.addEventListener('astro:page-load', adjustBackButtonPosition) window.addEventListener('resize', adjustBackButtonPosition) })() diff --git a/src/components/ui/CopyCode.astro b/src/components/ui/CopyCode.astro index 08ab9a7..16b1571 100644 --- a/src/components/ui/CopyCode.astro +++ b/src/components/ui/CopyCode.astro @@ -134,8 +134,8 @@ import { themeConfig } from '@/config' }) } + // Use only astro:page-load as it fires on initial load and navigation document.addEventListener('astro:page-load', initCopyCode) - document.addEventListener('DOMContentLoaded', initCopyCode)