I want to use window or document to return path of the current page default Astro.site.pathname isn't working right or proper documentation isn't available.
My question is how to use document or window properly in Astro JS?
Thanks in advance!
You need to write the script inside <script is:inline></script>
if you want to use things like window
or document
. This way Astro won't touch your JS and include it directly on the HTML. The JS positioned on the top of the page between --- ---
will be executed at build time.