#How to Add global js to Astro project

6 messages · Page 1 of 1 (latest)

wary ingot
#

Hello Everyone, I'm new to Astro and I'm trying to add a script to all my pages, what's the best way to do this.
My folder structure would be something like this. Also what's the best way to handle localization in astro. Thank you.

pages/
  en.md
  fr.md
  de.md
  etc
thorny jay
#

You can add a <script> tag to your layout and share it across all your pages. For localization there is a great recipe/guide on how to do this in the docs https://docs.astro.build/en/recipes/i18n/#recipe

Astro Documentation

Use dynamic routing and content collections to add internationalization support to your Astro site.

wary ingot
#

Thank you so much @thorny jay, I will give these a shot

#

I see now that I can use components from .astro files as I would in react, is this correct?

thorny jay
#

Yes you can use UI frameworks like React inside your .astro components https://docs.astro.build/en/concepts/islands/

Astro Documentation

Astro Islands (aka Component Islands) are a pattern of web architecture pioneered by Astro. “Islands architecture” was first coined by Etsy's frontend architect Katie Sylor-Miller in 2019, and expanded on by Preact creator Jason Miller.

wary ingot
#

Thank you so much