front-commerce-prepare.js
From the front-commerce-prepare.js file, Front-Commerce will call hooks that will let you customize some of those steps. This reference page documents the syntax of the exported module required by Front-Commerce.
The front-commerce-prepare.js configuration file should leave at the root of
any web modules folder. Front-Commerce supports the keys detailed below:
onCreateRoute
A function that transforms a route found in the modules defined in
.front-commerce.js:webModules.
See Routing reference for details about the terms used.
Parameters
route: an object with the following properties:fromModule(string): path of the web module defining the current routefilepath(string): absolute path to the route filepath(string):paththat will be used for mapping URLs to this file (see Routing reference for details)isLayout(bool): Is the file a_layout.js?isLayoutAddition(bool): Is the file a layout customization? (_error.jsor_inner-layout.js)isRoute(bool): Is the file a route (= neither a layout nor a layout addition)
Return value
An optional route object with the following keys:
fromModule(string): path of the web module defining the current routefilepath(string): absolute path to the route filepath(string):paththat will be used for mapping URLs to this file (see Routing reference for details)
If no route is returned, the route is ignored.
Example:
module.exports.onCreateRoute = (route) => {
// Remove all the `/contact/` pages
if (route.path === "/contact/") {
return null;
}
return route;
};