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

Proof of concept of using client-side script in astro #112

Conversation

pkong-ds
Copy link
Collaborator

@pkong-ds pkong-ds commented Aug 26, 2024

This PR is for demo purpose, will close after @YayunHuang read it.

Copy link
Collaborator Author

@pkong-ds pkong-ds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YayunHuang think there are 2 approaches I have. See if you can think of others/pick one here?

Also, please make sure lint still work on these ts files 🙏

Copy link
Collaborator Author

@pkong-ds pkong-ds Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach 1

  • keep scripts in src/pages
  • name ts/js files using document or window with _ prefxi

Copy link
Collaborator Author

@pkong-ds pkong-ds Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach 2

  • Move all astro files into other folders, e.g. src/componetns
    • Maybe even better, move all pages to src/astro-pages/
      • e.g. src/astro-pages/DeveloperToolsPage.astro
      • then, in src/pages/developerTools/index.astro, only import the src/astro-pages/DeveloperToolsPage.astro w/o any extra logic
      • that way, we can work around src/pages problem

rationale: only src/pages scripts are buggy

@YayunHuang
Copy link
Contributor

@pkong-ds seems approach 2 won't work too, I tried to put the pages to src/components and import the component in src/pages/xxxx.astro before and got same error document is not define, so let's use approach 1, thanks a lot! :adore2x: :adore2x:

@pkong-ds
Copy link
Collaborator Author

As per offline discussion, will use approach 1.

Lemme close this

@pkong-ds pkong-ds closed this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants