Create Page plugin
A plugin to create a new page.
Package name |
|
Repository link |
|
Latest version |
|
Changelog link |
Installing
The plugin doesn’t come pre-installed with Magnolia CLI.
You must add it to the mgnl.config.js
project file.
The plugin is installed automatically by the Jumpstart plugin if it is defined in a project template. |
Usage
Options
Form (short and long) | Description |
---|---|
|
Sets a light module for the page template.
By default, uses the directory specified in the |
|
Selects a page prototype. |
|
Displays the version. |
|
Displays help information. |
Examples
In the following examples, assume that the mgnl.config.js
file looks like this:
import CreatePagePlugin from "@magnolia/cli-create-page-plugin";
export default {
plugins: [
new CreatePagePlugin()
]
};
For more information, see Configuring plugins.
Create a new page
npm run mgnl -- create-page "my-page"
This command creates a new page called my-page
.
The plugin will prompt you to choose a:
-
Directory containing all light modules.
-
Specific light module where the
my-page
page will be created. -
Framework containing prototypes.
-
Prototype available in the framework.
-
Directory with all pages in the frontend project directory.
-
File containing the
componentMapping
object. -
Filetype of the newly generated page.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
componentMappingFilePath
-
type
-
-
Plugin
-
lightModule
-
framework
-
prototype
-
pagesSpaPath
-
Create a new page in a specific light module
npm run mgnl -- create-page "my-page" --light-module "my-lm"
This command creates a new page called my-page
in the my-lm
light module.
The plugin will prompt you to choose a:
-
Directory containing all light modules.
-
Framework containing prototypes.
-
Prototype available in the framework.
-
Directory with all pages in the frontend project directory.
-
File containing the
componentMapping
object. -
Filetype of the newly generated page.
If the my-lm
light module doesn’t exist yet in the light modules directory, the plugin will prompt you to select another one.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
componentMappingFilePath
-
type
-
-
Plugin
-
lightModule
-
framework
-
prototype
-
pagesSpaPath
-
Create a new component based on a specific prototype
npm run mgnl -- create-page "my-page" --prototype "card"
This command creates a new page called my-page
.
The plugin will prompt you to choose a:
-
Directory containing all light modules.
-
Specific light module where the
my-page
page will be created. -
Framework containing prototypes.
-
Prototype available in the framework.
-
Directory with all pages in the frontend project directory.
-
File containing the
componentMapping
object. -
Filetype of the newly generated page.
In case the card
prototype is not available in the framework, you’ll be prompted to choose a different prototype.
Prototype availability in the Create Page Plugin depends on the |
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
componentMappingFilePath
-
type
-
-
Plugin
-
lightModule
-
framework
-
prototype
-
pagesSpaPath
-
Configuration
You can set the following properties in mgnl.config.js
to predefine the plugin’s behavior.
Global properties
Property name | Description |
---|---|
|
The path to a directory containing all light modules. |
|
The name of a light module where the page will be created. Alternative forms: |
|
The path to the file containing the |
|
The type for the selected prototype, for example |
Plugin properties
Property name | Description | ||
---|---|---|---|
|
The name of a light module where the page will be created. Alternative forms: |
||
|
The path to the folder containing the frontend pages. |
||
|
The framework prototype to be used for page creation, for example |
||
|
Bypass the confirmation prompt when downloading the framework.
|
||
|
The name of a prototype. Alternative forms: |
||
|
A key-value object used by Handlebars for template rendering. |
||
|
A key-value object that determines how the prototype behaves. |
For more information, see Configuring plugins.