CLI Angular prototypes
This package can be used for Angular projects.
Package name |
|
Repository link |
|
Latest version |
|
Changelog link |
Prototypes in the package
For more details, click the prototype name.
Example usage
To see how to set and use the @magnolia/cli-angular-prototypes
, you can jumpstart a project based on the headless/angular-demo/ce
template.
-
Jumpstart a new project based on the template.
npx @magnolia/cli jumpstart -t "headless/angular-demo/ce"
The command downloads and creates a new project.
The
mgnl.config.js
file created:import CreatePagePlugin from "@magnolia/cli-create-page-plugin"; import CreateComponentPlugin from "@magnolia/cli-create-component-plugin"; ... export default { ... plugins: [ new CreatePagePlugin({ pagesSpaPath: './spa/angular-minimal/src/app/pages', framework: '@magnolia/cli-angular-prototypes@1', (1) prototype: 'basic', (2) templateArgs: { removeExtension: true, (3) namedImport: true (4) } }), new CreateComponentPlugin({ componentsSpaPath: './spa/angular-minimal/src/app/components', framework: '@magnolia/cli-angular-prototypes@1', (1) prototype: 'basic', (2) templateArgs: { removeExtension: true, (3) namedImport: true (4) } }), ... ], type: "ts", lightModulesPath: "./magnolia/light-modules", lightModule: "angular-minimal-lm", componentMappingFilePath: "./spa/angular-minimal/src/magnolia.config.ts" };
1 The framework prototypes package. 2 The prototype available in the framework prototypes package chosen. 3 Removes the extension in import strings. 4 Uses named imports instead of default. -
Create a new page.
npm run mgnl -- create-page main
-
Files created:
-
/<project-path>/magnolia/light-modules/angular-minimal-lm/dialogs/pages/main.yaml
Click to expand or collapse
label: Page Properties form: properties: title: label: Title $type: textField i18n: true
-
/<project-path>/magnolia/light-modules/angular-minimal-lm/templates/pages/main.yaml
Click to expand or collapse
title: main baseUrl: http://localhost:4200 routeTemplate: "/{language}{{@path}}" # templateScript: /angular-minimal-lm/webresources/build/index.html dialog: angular-minimal-lm:pages/main renderType: spa class: info.magnolia.rendering.spa.renderer.SpaRenderableDefinition areas: main: title: Main Area extras: title: Extras Area
-
/<project-path>/spa/angular-minimal/src/app/pages/main.component.ts
Click to expand or collapse
import { Component, Input } from '@angular/core'; import { RouterLink } from '@angular/router'; import { EditableArea } from '@magnolia/angular-editor'; @Component({ template: ` <div class="main"> <div>[main Page]</div> <h1>{{title || metadata['@name']}}</h1> <main> <div>[Main Area]</div> <div editable-area [content]="main" [parentTemplateId]="metadata['mgnl:template']"></div> </main> </div> `, styles: [``], standalone: true, imports: [EditableArea, RouterLink] }) export class main { @Input() title: any; @Input() main: any; @Input() extras: any; @Input() metadata: any; }
-
-
The modified file with the
componentMapping
object:-
/<project-path>/spa/angular-minimal/src/magnolia.config.ts
Click to expand or collapse
import { main as mainPage } from './app/pages/main.component' ... export const config = { 'componentMapping': { ... "angular-minimal-lm:pages/main": mainPage } };
-
-
Create a new component and make it available in the
main
page create before.npm run mgnl -- create-component hero -a main
-
Files created:
-
/<project-path>/magnolia/light-modules/angular-minimal-lm/dialogs/components/hero.yaml
Click to expand or collapse
label: hero form: properties: text: label: hero Text $type: textField i18n: true
-
/<project-path>/magnolia/light-modules/angular-minimal-lm/templates/components/hero.yaml
Click to expand or collapse
title: hero dialog: angular-minimal-lm:components/hero
-
/<project-path>/spa/angular-minimal/src/app/components/hero.component.ts
Click to expand or collapse
import { Component, Input } from '@angular/core'; @Component({ template: ` <h2>{{ text }}</h2> `, styles: [``], standalone: true }) export class hero { @Input() text: any; }
-
-
The modified main page file:
-
/<project-path>/magnolia/light-modules/angular-minimal-lm/templates/pages/main.yaml
Click to expand or collapse
... areas: main: title: Main Area availableComponents: hero: id: angular-minimal-lm:components/hero ...
-
-
The modified file with the
componentMapping
object:-
/<project-path>/spa/angular-minimal/src/magnolia.config.ts
Click to expand or collapse
import { hero as heroComponent } from './app/components/hero.component' ... export const config = { 'componentMapping': { ... "angular-minimal-lm:components/hero": heroComponent } };
-