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

Use comments instead of honox-island for marking islands #158

Open
yusukebe opened this issue Apr 23, 2024 · 3 comments
Open

Use comments instead of honox-island for marking islands #158

yusukebe opened this issue Apr 23, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@yusukebe
Copy link
Member

yusukebe commented Apr 23, 2024

What is the feature you are proposing?

This does not request a new feature but is about implementation.

Currently, to mark a component as an island component, we use hono-island tag like the following:

<honox-island component-name="/islands/badge.tsx" data-serialized-props='{"name":"Hono"}'>
  <div>
    Hey Hono!
  </div>
</honox-island>

But, this cause some problems:

So, instead, perhaps, we may use a comment:

<!--honox-island component-name:islands_badge.tsx data-serialized-props:'{"name":"Hono"}'-->
  <div>
    Hey Hono!
  </div>
<!--/honox-island-->

If this method will resolve some issues, we must try implementing it.

@yusukebe yusukebe added the enhancement New feature or request label Apr 23, 2024
@yasuaki640
Copy link

Just to confirm the direction, are you thinking of implementing a component that outputs HTML comments in SSR or something in that direction?

@yusukebe
Copy link
Member Author

Hi @yasuaki640

No particular direction. Either is fine if we can make it possible.

And, I'm not picky about using comments. If we can get the React hydration right and not break the HTML structure with it, it's OK.

@usualoma
Copy link
Member

The approach we should adopt is subtle, but the following code can be spit out of React, which may achieve the objective. 😵‍💫

<script>
  document.write('<!--honox-island component-name:islands_badge.tsx data-serialized-props:'{"name":"Hono"}'-->')
  document.currentScript.remove()
</script>
  <div>
    Hey Hono!
  </div>
<script>
  document.write('<!--/honox-island-->')
  document.currentScript.remove()
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants