Open
Description
I have found the new implementation for loading fresh islands, routes, and static files in Fresh 2.0 to have significant limitations.
- It is not possible to create middleware for static assets #2759
- It is not possible to add pages that inherit the app wrappers. As a result, it is difficult to create a plugin that adds pages, such as a user authentication plugin that includes a login page and inherits the page header. This makes it hard to separate features from a core app.
- Adding a route with JSX or an island is very difficult unless created with
fsRoutes
.
app.use(staticFiles());
await fsRoutes(app, {
dir: './',
loadIsland: (path) => import(`./islands/${path}`),
loadRoute: (path) => import(`./routes/${path}`),
});
I propose something like the following:
const router = new FSRouter(app);
accountPlugin(router);
router.loadIslandsDir('./islands/', import.meta.main)
.loadRoutesDir('./routes/', import.meta.main)
.loadStaticFiles('./static/', import.meta.main);
app.use(router.getMiddleware());
The developer can also prioritize the routes based on the order in which they add them.
Metadata
Metadata
Assignees
Labels
No labels
Activity