npm package: @magnolia-services/my-light-module
Description: Create and share Magnolia light modules.
Latest version: 1.0.2

# @magnolia-services/my-light-module

Create and share Magnolia light modules.

- [Creating the light module](https://docs.magnolia-cms.com/product-docs/6.2/Getting-started-with-Magnolia/Hello-Magnolia/Create-light-module.html) - Create the `hello-magnolia` module.
- [Sharing light modules](https://docs.magnolia-cms.com/product-docs/6.2/Support/Contribute/Finding-and-sharing-light-modules.html) – If you have some functionality that you think would be useful, like a component, consider sharing it with your fellow Magnolia developers.

## Quick Overview

### Start

```sh
npx mgnl install @magnolia-services/my-light-module --path .
```

It will create a directory called `my-light-module` inside the current folder.
Inside that directory, it will generate the initial project structure:

```
my-light-module
├── apps
├── contentTypes
├── decorations
├── dialogs
│   ├── components
│   └── pages
├── i18n
├── includes
├── restEndpoints
├── templates
│   ├── components
│   └── pages
├── virtualUriMappings
├── webresources
├── .gitignore
├── LICENSE
├── package.json
└── README.md
```

No configuration or complicated folder structures, only the files you need to build your light module.<br>

#### Folders Descriptions

##### apps

A Content app is a specialized app type for managing structured content. The content app user interface consists of a browser subapp and one or more detail subapps.  
Please, see [Automatically generated apps](https://docs.magnolia-cms.com/product-docs/6.2/Features/Content-Types.html#_automatically_generated_apps).

##### contentTypes

Allows defining Magnolia content types in a single YAML file of a light module.  
Please, see [Content type definition](https://docs.magnolia-cms.com/product-docs/6.2/Modules/List-of-modules/Content-Types-module/Content-type-definition.html).

##### decorations

Definition decoration is a mechanism which allows you to change existing configured items such as apps, dialogs, field types and templates.  
Please, see [Definition decoration](https://docs.magnolia-cms.com/product-docs/6.2/Developing/Definition-decoration.html).

##### dialogs

A dialog is a pop-up featuring some content and actions to conduct some operations on that content.
Please, see [Dialog definition](https://docs.magnolia-cms.com/product-docs/6.2/Developing/Templating/Dialog-definition.html).

##### i18n

Please, see [documentation page](https://documentation.magnolia-cms.com/display/DOCS/Internationalization).

##### includes

As a best practice, place YAML files here that do not represent full definitions, but are included by the definition files.
This prevents the problem where Magnolia tries to interpret an include file as a definition and ends up reporting that the file has problems.

##### restEndpoints

You can define multiple delivery endpoint.  
Please, see [Delivery API Configuration](https://docs.magnolia-cms.com/product-docs/6.2/Developing/API/Delivery-API.html#_configuration).

##### templates

A template definition gives a template a name and makes it available to the system.
Please, see [Template definition](https://docs.magnolia-cms.com/product-docs/6.2/Developing/Templating/Template-definition.html).

##### virtualUriMappings

Virtual URI mapping is a way to redirect an incoming request to the actual location of the content.  
Please, see [Virtual URI mapping](https://docs.magnolia-cms.com/product-docs/6.2/Administration/URI-mapping/Virtual-URI-mapping.html).

##### webresources

Folder with scripts, stylesheet or other resource files.
Please, see [Web resources](https://docs.magnolia-cms.com/product-docs/6.2/Developing/Resources.html#_web_resources).

### Modify

Modify the folder name to match your light module.  
Modify the `package.json` file to match your light module.  
Create all files for your light module.

### Publish to npm

```sh
npm publish
```

Magnolia provides a set of guidelines to make sure that light modules are easy to find and use by the community, but still ensure that the creator has total flexibility in how their light module is built.

| Guideline    | Details                                                                                                                                                                                                                                                          |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Findable     | Include the magnolia-light-module keyword in the npm `package.json` file to make it easy for people to discover your module.                                                                                                                                     |
| Ready-to-use | Publish your light module to npm in a ready-to-use state. A developer should be able to take the package from npm, drop it in their `magnolia.resources.dir` (or light-modules directory), and then configure availability and how to include the web resources. |
| README       | Provide a complete `README.md` file to help people understand and use your module.                                                                                                                                                                               |

## License

@magnolia-services/my-light-module is open source software [licensed as MIT](https://git.magnolia-cms.com/projects/INCUBATOR-LIGHT-MODULES/repos/my-light-module/browse/LICENSE).