CLI Angular prototypes

This package can be used for Angular projects.

Package name

@magnolia/cli-angular-prototypes

Repository link

Latest version

Magnolia CLI angular prorotypes latest version tag

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.

  1. 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.
  2. Create a new page.

    npm run mgnl -- create-page main
  3. 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;
      }
  4. 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
         }
        };
  5. Create a new component and make it available in the main page create before.

    npm run mgnl -- create-component hero -a main
  6. 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;
      }
  7. 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
      ...
  8. 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
         }
        };
Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Magnolia CLI docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules