Skip to content

Support for programmatic updates to Virtual Templates? #3662

Description

@ech0-de

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions