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 for programmatic updates to Virtual Templates? #3662

Open
ech0-de opened this issue Feb 20, 2025 · 0 comments
Open

Support for programmatic updates to Virtual Templates? #3662

ech0-de opened this issue Feb 20, 2025 · 0 comments

Comments

@ech0-de
Copy link

ech0-de commented Feb 20, 2025

Is your feature request related to a problem? Please describe.

I'm currently migrating a site to Eleventy and the way we would like to do i18n doesn't line up with the approaches shown in the documentation. Alternative language files should reside in the same directory with a language suffix (i.e., index.en.html and index.de.html). If a page is not localized it should fallback to the other language and add a note that the content is not localized.

I've been able to build this behavior by scanning input files and adding missing localizations as virtual templates. However, when using the dev server, changes to the original file, will not update the virtual fallback page.

I was then attempting to watch for changes to the original file and trigger an update to the virtual template, by calling addVirtualTemplate again, which results in an error: Virtual template conflict: you can’t add multiple virtual templates that have the same inputPath.

Describe the solution you'd like

I would like to be able to call an updateVirtualTemplate function, which takes the new content of the virtual template and properly build and update the page if it's currently previewed in a browser.

Describe alternatives you've considered

Maybe using virtual templates to achieve this was incorrect in the first place. I also considered relying on pagination for this, but decided against it, because the pages themselves may require pagination.

Additional context

Our approach to localization is probably a niche application, but having the option to asynchronously update virtual templates, can be very beneficial for other use cases as well.

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

1 participant