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

Support loading islands from a URL #25

Open
KonnorRogers opened this issue Jul 8, 2024 · 2 comments
Open

Support loading islands from a URL #25

KonnorRogers opened this issue Jul 8, 2024 · 2 comments

Comments

@KonnorRogers
Copy link

KonnorRogers commented Jul 8, 2024

Prior Art: https://turbo.hotwired.dev/reference/frames#lazy-loaded-frame

<turbo-frame id="messages" src="/messages" loading="lazy">
  Content will be replaced when the frame becomes visible and /messages has been loaded.
</turbo-frame>

Maybe don't need the loading, but being able to load a route on client:visible would be 🤌

Something like:

<is-land client:visible src="/island-1.html">
  <!-- Injects HTML from `src` here: -->
</is-land>

Happy to discuss further!

@zachleat
Copy link
Member

zachleat commented Jul 9, 2024

I do this pattern quite a bit but pairing it with an html-fetch custom element:

Definition: https://github.com/11ty/11ty-website/blob/67b3b23154110846c71ebe7857e63de8efd51e07/src/_includes/components/html-fetch.js#L2

Example use: https://github.com/11ty/11ty-website/blob/67b3b23154110846c71ebe7857e63de8efd51e07/src/_includes/supporters.njk#L24-L29

The simplest usage would be:

<is-land on:visible><html-fetch src="/imports/supporters.html"></html-fetch></is-land>

@zachleat
Copy link
Member

zachleat commented Jul 9, 2024

Maybe I need to package up html-fetch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants