Description
The page system is the main way to define the routes and there doesn't seem to way to define base routes outside of the filesystem, see issue. This creates a situation where the page is difficult to reuse without moving data outside of the page. Although that is acceptable this disconnects the data (html / component / metadata) from the page and routing. This means that there is no guarantee that the data is actually connected to the route and Vike route information / hooks is difficult to wire together. I don't think this is a major problem, but I think there should be public methods to access page data other than the current page or to be able to register routes programmatically. Programatically defining routes by default solves this issue as then the data can be connected routes in user land and is thus available via normal means. There should be some method to have the route information associated with the page as well.
This can already done by accessing private properties in the context, namely context._pageConfigs. I think there's also some plugins using vike/__internals to access this data. I think these should just be made public and more clearly accessible instead of the current data:
const pageEntry = pageConfig.loadVirtualFilePageEntry().moduleExportsPromise
const page = pageEntry.configValuesSerialized.Page.valueSerialized.exportValues.default
Concrete examples:
User attempts to load an product page, but something in the page goes wrong and cannot be recovered. I would like to be access the error page.
User wants to log in a page that has persistent data, I would like to show the component from the login page in a dialog.
Description
The page system is the main way to define the routes and there doesn't seem to way to define base routes outside of the filesystem, see issue. This creates a situation where the page is difficult to reuse without moving data outside of the page. Although that is acceptable this disconnects the data (html / component / metadata) from the page and routing. This means that there is no guarantee that the data is actually connected to the route and Vike route information / hooks is difficult to wire together. I don't think this is a major problem, but I think there should be public methods to access page data other than the current page or to be able to register routes programmatically. Programatically defining routes by default solves this issue as then the data can be connected routes in user land and is thus available via normal means. There should be some method to have the route information associated with the page as well.
This can already done by accessing private properties in the context, namely
context._pageConfigs. I think there's also some plugins usingvike/__internalsto access this data. I think these should just be made public and more clearly accessible instead of the current data:const pageEntry = pageConfig.loadVirtualFilePageEntry().moduleExportsPromiseconst page = pageEntry.configValuesSerialized.Page.valueSerialized.exportValues.defaultConcrete examples:
User attempts to load an product page, but something in the page goes wrong and cannot be recovered. I would like to be access the error page.
User wants to log in a page that has persistent data, I would like to show the component from the login page in a dialog.