Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Vanilla JS ] Examples how should be use #1793

Closed
ampmonteiro opened this issue Oct 13, 2022 · 3 comments
Closed

[ Vanilla JS ] Examples how should be use #1793

ampmonteiro opened this issue Oct 13, 2022 · 3 comments
Assignees
Labels
add new content Document something that is not in docs. May require testing, confirmation, or affect other pages.

Comments

@ampmonteiro
Copy link

The same way you have a section about UI framework, i think should exist a section with vanilla js because the section astro components > client-side scripts is incomplete or too vague ( https://docs.astro.build/en/core-concepts/astro-components/#client-side-scripts).

In the section about vanilla js should exist clear examples as well as should exist a template for that in the cli and in astro.new.

@sarah11918 sarah11918 added the add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. label Oct 14, 2022
@sarah11918
Copy link
Member

Hi @ampmonteiro, thanks for this comment! I've been writing these Vanilla JS examples for our new tutorial this week, in fact! Once that is in our docs, we can think about where it might make sense to put some examples of things you can build with script tags only, without needing a framework.

I like your idea for a starter template that has some common website features pre-built with vanilla JS, like a theme toggle, navigation show/hide.

@ampmonteiro
Copy link
Author

hi @sarah11918 ,
i create this issue in sequence of this issue that i create in your astro repo ( withastro/astro#5083),
and because even dont know where you should put you script tags, only in pages or you can put in components? is that best practice? when is bundling into separate file, when is not? And how i config to always bundle into separate file?

I think this are import questions to be answer in the docs, mainly with practical examples.

Beside of examples that you mention, i think should be mention how, p.e, load a json file from public folder without the need to reach to static endpoint ( https://docs.astro.build/en/core-concepts/endpoints/#static-file-endpoints) like i shown in issue i mention ( that also should be in Data Fetching section ( with subtitle vanilla js but also is valid for frameworks since should work the same way).

thanks

@sarah11918
Copy link
Member

Closing this because we now have a page on scripts and event handling! https://docs.astro.build/en/guides/client-side-scripts/ to address the main concern here! 🥳

I do still like the idea of "recipes" for creating a theme toggle, nav bar etc. in plain JS. But for now, we do have those in the tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add new content Document something that is not in docs. May require testing, confirmation, or affect other pages.
Projects
None yet
Development

No branches or pull requests

3 participants