Create Content Type plugin
A plugin to create a content type in a light module.
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. |
With add-plugin
Run the following command in the project folder.
npm run mgnl -- add-plugin @magnolia/cli-create-content-type-plugin
|
Windows users using PowerShell must enclose the two consecutive hyphens (
|
The command automatically downloads, installs, and registers the plugin in mgnl.config.js.
Usage
Options
| Form (short and long) | Description |
|---|---|
|
Configure a content app and an associated workspace by creating a new app or choosing an existing one. We recommended using plural form for the |
|
Sets a light module for the content type.
By default, the |
|
Use the specified path to the custom prototype templates directory as the prototype source for content type creation. |
|
Selects a prototype for content type creation. |
|
Displays the version. |
|
Displays help information. |
Examples
In the following examples, assume that the mgnl.config.js file looks like this:
import CreateContentTypePlugin from "@magnolia/cli-create-content-type-plugin";
export default {
plugins: [
new CreateContentTypePlugin()
]
};
For more information, see Configuring plugins.
Create a new content type
npm run mgnl -- create-content-type "my-ct"
|
Windows users using PowerShell must enclose the two consecutive hyphens (
|
This command creates a new content type called my-ct based on the _default prototype.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new content type will be created.
The plugin writes the following properties to the mgnl.config.js file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Create a new content type with a specific app
npm run mgnl -- create-content-type "my-ct" --app "my-app"
|
Windows users using PowerShell must enclose the two consecutive hyphens (
|
This command creates a new content type called my-ct based on the _default prototype with the my-ct content type.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new content type will be created.
If the my-app app doesn’t exist in the light module directory, it is created automatically.
The plugin writes the following properties to the mgnl.config.js file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Create a new content type in a specific light module
npm run mgnl -- create-content-type "my-ct" --light-module "my-lm"
|
Windows users using PowerShell must enclose the two consecutive hyphens (
|
This command creates a new content type called my-ct based on the _default prototype in the my-lm light module.
The plugin will prompt you to choose a directory containing all light modules.
If the my-lm light module doesn’t exist 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
-
-
Plugin
-
lightModule
-
Create a new content type based on a prototype from a custom prototypes directory
npm run mgnl -- create-content-type "my-ct" --prototype-dir "/path/to/custom-prototypes-dir/app-content-type"
|
Windows users using PowerShell must enclose the two consecutive hyphens (
|
This command creates a new content type called my-ct based on the _default prototype from /path/to/custom-prototypes-dir/app-content-type.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new content type will be created.
If the _default prototype is not present in the custom prototypes directory, it will prompt you to choose another prototype.
The plugin writes the following properties to the mgnl.config.js file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule -
prototypeDir -
prototype
-
|
The structure of the
To use the custom
|
|
Windows users using PowerShell must enclose the two consecutive hyphens (
|
Create a new content type based on a specific prototype
npm run mgnl -- create-content-type "my-ct" --prototype "custom-prototype-name"
|
Windows users using PowerShell must enclose the two consecutive hyphens (
|
This command creates a new content type called my-ct based on the custom-prototype-name prototype.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new content type will be created.
If the custom-prototype-name prototype is not present, it will prompt you to choose another prototype.
|
The Create Content Type plugin only contains the To choose a custom prototype from the custom prototypes directory, use the |
The plugin writes the following properties to the mgnl.config.js file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule -
prototype
-
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 content type will be created. Alternative forms: |
Plugin properties
| Property name | Description |
|---|---|
|
The name of a light module where the content type will be created. Alternative forms: |
|
The path to a custom prototypes directory. Alternative forms: |
|
The name of a prototype. Alternative forms: |
For more information, see Configuring plugins.