CLI Vue prototypes
This package can be used for Vue 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-vue-prototypes
, you can jumpstart a project based on the headless/vue-demo/ce
template.
-
Jumpstart a new project based on the template.
npx @magnolia/cli jumpstart -t "headless/vue-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/src/templates/pages', framework: '@magnolia/cli-vue-prototypes', (1) prototype: 'mhd', (2) templateData: { port: '8181' } }), new CreateComponentPlugin({ componentsSpaPath: './spa/src/templates/components', (1) framework: '@magnolia/cli-vue-prototypes', (2) prototype: 'mdh' }), ... ], type: "vue", lightModulesPath: "./light-modules", lightModule: "spa-lm", componentMappingFilePath: "./spa/src/magnolia.config.js" };
1 The framework prototypes package. 2 The prototype available in the framework prototypes package chosen. -
Create a new page.
npm run mgnl -- create-page main
-
Files created:
-
/<project-path>/light-modules/spa-lm/dialogs/pages/main.yaml
Click to expand or collapse
label: Page Properties form: properties: title: label: Title $type: textField i18n: true
-
/<project-path>/light-modules/spa-lm/templates/pages/main.yaml
Click to expand or collapse
renderType: spa class: info.magnolia.rendering.spa.renderer.SpaRenderableDefinition title: main dialog: spa-lm:pages/main baseUrl: http://localhost:8181 routeTemplate: '/{language}{{@path}}' areas: main: title: Main Area extras: title: Extras Area
-
/<project-path>/spa/src/templates/pages/main.vue
Click to expand or collapse
<script lang="js"> export default { name: 'main', }; </script> <script setup lang="js"> import { EditableArea } from '@magnolia/vue-editor'; const { title, main, extras, metadata } = defineProps({ title: String, main: Object, extras: Object, metadata: Object }); </script> <template> <div class="main"> <h1>{{ title || metadata['@name'] }}</h1> <main> <div>[Main Area]</div> <EditableArea v-if="main" v-bind:content="main" /> </main> <div> <div>[Extras Area]</div> <EditableArea v-if="extras" v-bind:content="extras" /> </div> </div> </template>
-
-
The modified file with the
componentMapping
object:-
/<project-path>/spa/src/magnolia.config.js
Click to expand or collapse
import mainPage from './templates/pages/main.vue' ... const config = { componentMappings: { ... "spa-lm:pages/main": mainPage } }; export default config;
-
-
Create a new component and make it available in the
main
page created before.npm run mgnl -- create-component hero -a main
-
Files created:
-
/<project-path>/light-modules/spa-lm/dialogs/components/hero.yaml
Click to expand or collapse
label: hero form: properties: text: label: hero Text $type: textField i18n: true
-
/<project-path>/light-modules/spa-lm/templates/components/hero.yaml
Click to expand or collapse
title: hero dialog: spa-lm:components/hero
-
/<project-path>/spa/src/templates/components/hero.vue
Click to expand or collapse
<script lang="js"> export default { name: 'hero', }; </script> <script setup lang="js"> const { text } = defineProps({ text: String, }); </script> <template> <h2>{{ text }}</h2> </template>
-
-
The modified
main
page file:-
/<project-path>/light-modules/spa-lm/templates/pages/main.yaml
Click to expand or collapse
... areas: main: title: Main Area availableComponents: hero: id: spa-lm:components/hero ...
-
-
The modified file with the
componentMapping
object:-
/<project-path>/spa/src/magnolia.config.js
Click to expand or collapse
import heroComponent from './templates/components/hero.vue' ... const config = { componentMappings: { ... "spa-lm:components/hero": heroComponent } }; export default config;
-